Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple Inheritance

 
Bala jee
Ranch Hand
Posts: 36
  • 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
Posts: 15494
43
Android IntelliJ IDE Java Scala Spring
  • 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
  • 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?!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic