• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

interface and abstract real time Advantages

 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys ...
let me know real time issues where it absract and interface will be used ...
Since java denies multiple inheritance , so we will be using interface ...
wher in the case trully speaking mul;tiplr inheritance we have neither implemented mtds but interfaces is noit like that ..
class which implenmnts sud provide the defn then what is use
Thx in advnace
Gowtham gowtham.ganamukala@gmail.com
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One word: Polymorphism. That's the use...
 
kiennjal shah
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, thats one of the main benefits of OOP, polymorphism.

For instance, you can have an interface as:




now I may have many classes such as Ferrari, Porche etc.. which can benefit by using this public abstract method of the interface car w/o having to rewrite the method again and again. Also we can set some variables in the interface (which btw, are public static and final by default) and benefit by using them in various classes.

Hope this helps.

-Kiennjal
[ March 30, 2005: Message edited by: kiennjal shah ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic