File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Java Multiple Inheritance. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Java Multiple Inheritance." Watch "Java Multiple Inheritance." New topic

Java Multiple Inheritance.

Ganesh Prakhya
Ranch Hand

Joined: May 05, 2004
Posts: 76
Hi All,

Today me and my friend had a discussion, he argued that Java supports multiple inheritance by implementing many interfaces. I argued that by providing implementation for empty methods from interface, thats not going to be multiple inheritance, we are simply using method signatures from interface and its a contract between interface and class.

"My implementing an interface the class is promising that, it is going to provide implementation for all the methods in implemented interface."

Java does not support multiple inheritance by implementing many interfaces.

Pl. correct if I am wrong in my discussion with my friend.

Thanks & Regards,
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I would say that Java provides a limited version of multiple inheritence. However, it does not provide "complete" multiple inheritence like you see in other OO languages like C++ that allow you to inherit implementation as well as the interface.


Java API Documentation
The Java Tutorial
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

I thought that Java refrained people from doing multiple inheritance, because it's bad design and calls for problems. That is why you can extend only one class. I do not consider implementing interfaces as being inheritance.
Maybe wrong.

[My Blog]
All roads lead to JavaRanch
Dave Tuttle
Ranch Hand

Joined: Jan 18, 2006
Posts: 34
Hi Ganesh,
You are correct. Implementing interfaces is not multiple inheritance.
With inheritance, the class is gaining funcionality from the base class. With implementation, the class is gaining no functionality - just the 'appearance'.
Inheritance is a 'is a' relationship.
Implentation is a 'looks like, but isn't' relationship.
I hope I explained that well.
ddd aaa

Joined: Mar 17, 2006
Posts: 2
marc weber

Joined: Aug 31, 2004
Posts: 11343

"ddd aaa,"

Welcome to JavaRanch!

Please revise your display name to meet the JavaRanch Naming Policy. To maintain the friendly atmosphere here at the ranch, we like folks to use real (or at least real-looking) names. You can edit your name here. Thank you for your prompt attention!


PS: Note that if class A implements an interface B, then an instance of A "is-a" B. Or as Bruce Eckel says in Thinking in Java, interfaces allow a "variation of 'multiple inheritance' by creating a class that can be upcast to more than one base type." (Page 316 of the new 4th edition.)
[ March 17, 2006: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
I agree. Here's the link:
subject: Java Multiple Inheritance.
It's not a secret anymore!