This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java & Multiple Inheritance

 
Vinoth Kumar Kannan
Ranch Hand
Posts: 276
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15288
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48980
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 48980
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Thank you.

you are welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic