File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Jobs Discussion and the fly likes Does JAVA support multiple inheritance or not Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Careers » Jobs Discussion
Bookmark "Does JAVA support multiple inheritance or not" Watch "Does JAVA support multiple inheritance or not" New topic

Does JAVA support multiple inheritance or not

James Bellan

Joined: Nov 05, 2007
Posts: 9
Hi Arulkumaran,

On a specific Interview i have been asked this question and till now i dont have any answers to get this one correctly / perfectly.

Q >> By default every class in Java inherits the "OBJECT" class , so any class is extended by this "OBJECT" class. If i try to extend some other class i think it is extended twice? Is this not multiple inheritance.

Eg: MyClass extends ParentClass (also extends Object class by default).
How this is managed / Or is this exceptional / How does JVM support only this inheritance?

Don Stadler
Ranch Hand

Joined: Feb 10, 2004
Posts: 451
No, it is not multiple inheritance. It is a chain of single inheritance.

Put it this way: I can write class A which extends Object, Class B which extends A, and Class C which extends B. It's single inheritance all the way.
Dave Hewy
Ranch Hand

Joined: Aug 21, 2003
Posts: 93
Strictly speaking Don is right, you can only specify one class after the extends keyword.

But when you add interfaces into the mix it is possible to engage in multiple "contracts" - similar in many ways to extending several abstract classes that have abstract methods with no implementation.

I've seen many a thread of discussion on Java multiple inheritance !
Sue Pillai
Ranch Hand

Joined: Nov 04, 2004
Posts: 89
I think the answer should be "yes and no"

Java supports multiple inheritance in interfaces but not in implementations.
If asked why no multiple inheritance of implementations, then the answer is simply "simplicity". Java follows the age of C++, but is a stickler for OOP principles. Creators of Java wanted to get rid of the complexity of multiple inheritance (of implementations) that is inherent in C++.

Hope it helps


SCJP 1.2
Mark Herschberg

Joined: Dec 04, 2000
Posts: 6037
Sue's answer is the one I (and most other hiring managers I know) look for when asking that question.

James Bellan

Joined: Nov 05, 2007
Posts: 9
Thanks for all that answers Guys.
I am clear now.
I agree. Here's the link:
subject: Does JAVA support multiple inheritance or not
It's not a secret anymore!