This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple Inheritance

 
Bala jee
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Why java does not support multiple inheritence While C++ Supports the same?
What is the drawback Java will face if it supports Multiple in heritance?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java does support a form of multiple inheritance; a class can implement more than one interface. But in Java you can't extend multiple classes.

You never really need this in real applications, and it leads to problems like the diamond problem. In C++ this is solved by making things more complicated - you can choose between virtual inheritance and non-virtual inheritance in C++.

One of the goals that the designers of the Java language had was to make it simpler than C++, so they decided to not support multiple inheritance in Java.
 
Peter Chase
Ranch Hand
Posts: 1970
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jesper Young:
One of the goals that the designers of the Java language had was to make it simpler than C++


That's not exactly a difficult goal to achieve is it?!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic