aspose file tools*
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "Does Java Support Multiple Inheritance" Watch "Does Java Support Multiple Inheritance" New topic
Author

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!
http://www.javaworld.com/javaqa/2002-07/02-qa-0719-multinheritance.html

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
Greenhorn

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
Sheriff

Joined: Oct 13, 2005
Posts: 39784
    
  28
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