wood burning stoves 2.0*
The moose likes Java in General and the fly likes Does Java Support Multiple Inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Does Java Support Multiple Inheritance" Watch "Does Java Support Multiple Inheritance" New topic

Does Java Support Multiple Inheritance

N.Senthil Kumar
Ranch Hand

Joined: Jul 07, 2009
Posts: 50
Hi Friends,

In Java, Multiple Inheritance is supported by means of Interface. (Correct me if i am Wrong)

class B extends A {}

Now the Class B has A as SuperClass. And Object is the SuperClass for All Java Classes..

then B has A and Object as SuperClass ..

Does it mean Multiple Inheritance. If yes. how it is.

Please Explain me.

Thanks in advance.

N.Senthil Kumar
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Consider below code

it is not a multiple inheritance , it is a multi-level inheritance
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Java doesn't support multiple inheritance because it makes the code complicated and there were more cons than pros!

And the example that you gave is a Multi-Level one as clarified by Seetharaman not a multiple one!
N.Senthil Kumar
Ranch Hand

Joined: Jul 07, 2009
Posts: 50
Thanks Guys.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

N.Senthil Kumar wrote:Thanks Guys.

You are Welcome
Evan Caballero
Ranch Hand

Joined: Dec 10, 2009
Posts: 59
The only multiple inheritance you can have in java is when implementing interfaces. You can implement not only one inferface, but two, or three, or N.

But this will only modify the behaviour of your objects, not their actual state.
april henry

Joined: Jan 18, 2010
Posts: 9
Hi N.Senthil Kumar
In java, class doesn't support multiple inheritance but interface does.
Please remember:java supports single inheritance but multi-realization.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 37943
Maybe more accurate to say that interfaces allow Java to mimic multiple inheritance.

And April Henry: you seem to be new: welcome to the Ranch
I agree. Here's the link: http://aspose.com/file-tools
subject: Does Java Support Multiple Inheritance
Similar Threads
Class Object and Hierarchy
Object class by default break to rule of multipul inheritance
multiple inheritance
doubt on inheritance?
Java does not support multiple inheritance...?