Why java does not have multiple inheritance?but in c++ ?

Showing Answers 1 - 9 of 9 Answers

Amit Rana

  • Aug 16th, 2006
 

Java supports the multiple inheritance but only in interfaces. It means you can implements more than one interfaces but you can't extends more than one classes. So we can't say that Java doesn't support multiple inheritance.

  Was this answer useful?  Yes

saumendra11

  • Aug 16th, 2006
 

java doesnot support multiple inheritance.in c++ ,there is a ambiguty problems occers due to multiple inheritance.

  Was this answer useful?  Yes

praveenkumar

  • Sep 7th, 2006
 

C++ is apt languge for both commercial and scientific applications but C++ has bit of complexity with multiple inheritnce Java emphasis in commercial applications it tried to eliminate the complex bit

  Was this answer useful?  Yes

kathie siera

  • Sep 14th, 2006
 

it can using implementing multiple interfaces...

but its a big concept batter u go through head first series JAVA

  Was this answer useful?  Yes

The main reason that Multiple Inheritance was omitted from Java was because from a design perspective, muliple inheritance will cause problems. It may seem to us that it solves many problems but eventually, it also creates problems along with complexity. So the very objective of java being "Simple" gets defeated. Therefore the founders of java have cut Multiple Inheritance from the language.

Just a point to add that, mulitple interface inheritance is perfectly allowed. This idea was brought up from C's protocols.

Thanks,

Ram

  Was this answer useful?  Yes

yes this is absoluetly true, in java we dont hav multiple inhet. actually multiple inheritance means a drive class is having mare than one base class. just as it will create the popular diomound problem

eg. class A is a bAse class

Class B and Class C are its drive classes

and Class d is inheting both B and C

then if D's object tries to acces a method from its base class then whos method will be called (Weather from B or C)this was the problem and C++ makes THe Virtual base class to solve it. but java doesnt support it bcoz it create more problem then solving .

  Was this answer useful?  Yes

Multiple inheritance in Java is supported by the use of Interfaces.

You do not have direct multiple inheritance because Java is a programming language which is kept simple.
And using multiple inheritance keeps on complicating things.
Java using extends to extend only one class.  To implement multiple inheritance you can use implement interfaces.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions