File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Class Inheritance and Interface Inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Class Inheritance and Interface Inheritance" Watch "Class Inheritance and Interface Inheritance" New topic

Class Inheritance and Interface Inheritance

Anjaneya Ram

Joined: Jan 23, 2004
Posts: 16
what is the difference between Class inheritance and interface inheritance.Please provide an example. Thanks in Advance.

Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
Moving to Java in General(beginner) forum...

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
As far as I know, there isn't a difference except the differences that exist between classes and interfaces themselves.

Java API Documentation
The Java Tutorial
Jason Fox
Ranch Hand

Joined: Jan 22, 2004
Posts: 114
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.
Lalit K Kumar
Ranch Hand

Joined: Jan 29, 2004
Posts: 32
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 ]
I agree. Here's the link:
subject: Class Inheritance and Interface Inheritance
It's not a secret anymore!