• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Class Inheritance and Interface Inheritance

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the difference between Class inheritance and interface inheritance.Please provide an example. Thanks in Advance.

Ram.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to Java in General(beginner) forum...
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, there isn't a difference except the differences that exist between classes and interfaces themselves.
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's simple, actually. First, when you inherit from a superclass, you automatically inherit all of its methods (except in the case of an abstract class) and have all of the default implementation. For example, when extend Applet, you get methods like add() and repaint() which are immediately usable by you with no coding. When you impliment an interface, you are saying basically 'I promise to implement all of the necessary methods in order for anyone to use this class as a <INTERFACE>. For example, when you implement Runnable, you must write a method called run() with the signature public void run(), because you are saying that the class (or object) is Runnable, so anyone using it can use the run() method. Its designed so that everyone is always on the same page, every Runnable object has a run() method, every ActionListener has an actionPerformed(ActionEvent) method, etc. Helps clear up confusion.
Jason
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
whenever you inherit from a class you get all the methods of superclass automatically inherited. you can apply your own implementation if you wish (but it is'nt necessary)
if you inherit from an interface you are bound to implement all the methods contained in the interface,
[ February 20, 2004: Message edited by: Lalit K Kumar ]
reply
    Bookmark Topic Watch Topic
  • New Topic