aspose file tools*
The moose likes Beginning Java and the fly likes Java & Multiple Inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java & Multiple Inheritance" Watch "Java & Multiple Inheritance" New topic
Author

Java & Multiple Inheritance

Vinoth Kumar Kannan
Ranch Hand

Joined: Aug 19, 2009
Posts: 276

From the very moment I learnt Java doesnt support multiple inheritance, the question raised in me...Why not multiple inheritance?Whats going to really go wrong when someone extends more than 1 class?Its kind of bugging me... Any real reason???Wondering what that might be..


OCPJP 6
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14345
    
  22

Welcome to JavaRanch.

Your question is a frequently asked question. It was last asked just a few days ago. Please search for "multiple inheritance" and you'll find more discussions about this topic:

Java Doesn't support Multiple inheritance
Why one can't extend more than one class
multiple inheritance
multiple inheritance in java

The diamond problem is a problem that multiple inheritance causes.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

welcome to javaranch

page no 100....kathy book says......simple explaination ever why java doesnot support multiple inheritance

Some languages (like C++) allow a class to extend more than one other class.
This capability is known as "multiple inheritance." The reason that Java's
creators chose not to allow multiple inheritance is that it can become quite
messy. In a nutshell, the problem is that if a class extended two other classes,
and both superclasses had, say, a doStuff() method, which version of doStuff()
would the subclass inherit? This issue can lead to a scenario known as the
"Deadly Diamond of Death," because of the shape of the class diagram that
can be created in a multiple inheritance design. The diamond is formed when
classes B and C both extend A, and both B and C inherit a method from A. If
class D extends both B and C, and both B and C have overridden the method
in A, class D has, in theory, inherited two different implementations of the
same method. Drawn as a class diagram, the shape of the four classes looks
like a diamond.


SCJP6.0,My blog Ranchers from Delhi
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39828
    
  28
shanky sohar wrote:page no 100....kathy book . . .
Do you mean Kathy Sierra? She helped found JavaRanch. But she has written several books: which one do you mean?
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

Campbell Ritchie wrote:
shanky sohar wrote:page no 100....kathy book . . .
Do you mean Kathy Sierra? She helped found JavaRanch. But she has written several books: which one do you mean?

yes kathy sierra......scjp1.6.........page no 100
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39828
    
  28
Thank you.
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

Campbell Ritchie wrote:Thank you.

you are welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java & Multiple Inheritance