Why java does not support Multiple Inheritance?Why java is not pure Object Oriented?

Showing Answers 1 - 55 of 55 Answers

pazhani subramaniam

  • Oct 2nd, 2005
 

coz different classes may have different varible with same name that may be be contadicted and can cause confusions resulting in errors

  Was this answer useful?  Yes

simply because java programmers found that this concept is not so useful and also the effort required to handle this is much.So in short v can say that its bad effects were more than its advantages.

  Was this answer useful?  Yes

Java absolutly support multiple inheritence in terms of Interface.We can extend one class only to avoid ambiguity problem.In interface we have to define the functions.So we don't get any ambiguity.In c++ it is big problem with multiple inheritence but in JAVA this thing is improved by introducing Interfaces

chanakya

  • Sep 30th, 2006
 

you have given the wrong ans same thing can happen with interfaces also but the ans below is correct

  Was this answer useful?  Yes

Basil

  • Sep 14th, 2007
 

Java is vast, but implements simplicity avoiding ambiguity of methods and variables in multiple inheritence. This also saves memory and has simplicity.

  Was this answer useful?  Yes

sampra

  • Mar 11th, 2008
 

java is not supporting multiple inhertice to avoid ambiguity sun guys has not allso this ...
java is supporting primitive that is non object data type so java cant called as purly object oriented language

  Was this answer useful?  Yes

Java does not support multiple inheritance directly but it supports multiple inheritence through interface.
Because when we extends more than one class, JVM get some abigious problem.
i.e. JVM get confusion which method it will take. 

Java is not totally pure because it has primitives. If you look at other languages like Ruby, Smalltalk, etc. they are "purer" because they don't distinguish between objects and primitives.

  Was this answer useful?  Yes

kuldeep0702

  • Oct 30th, 2009
 

Main reason is Diamond problem (ambiguity) during which JVM get the confusion that
is why Java does not support the multiple inheritance. Throw interface we use the multiple inheritance but it is the alternative method in
Java for getting the multiple inheritance because interface not part of inheritance it is a part of aggregation. Extends is part of inheritance.
Getting multiple inheritance firstly we extend and the implement the interface here extends and implement both
are different and process for same name function.

  Was this answer useful?  Yes

prasobh.k

  • Oct 22nd, 2010
 

Let me explain with a example.


Suppose consider a method test() which is in class Z.


Suppose a programmer ABCD inherited the class Z to class X and overrided the
test(). So this class will have the new implementation of test().
Suppose a programmer DEF inherited the class Z to class Y and overrided the funX().
So this class will have the new implementation of test().


If Multiple Inheritance is permitted in java, then if the new programmer
inherited both the classes and he didn't done any overriding of method test()
then if he calls the test() ,the JVM will not know which method to call i.e.,
either the method in class X or method in class Y.


Because of this inconsistencies, Multiple inheritance is not permitted in
java.


Madhuri

  • Jul 24th, 2012
 

We all see the features of java, in this Java is simple & object-oriented programming language. Multiple Inheritance is complex to understand Hence java not support Multiple Inheritance.

Also in C++ we inherit class by using :: ,But in Java we not use :: operator ,we only use extends keyword.

  Was this answer useful?  Yes

AMIT GURJAR

  • Sep 21st, 2012
 

If we have two class, class X and Class Y,and both class have a same name method for example void show(),now we want to inherit both the class in a new child class name Z,When we call that method which is comman in both the parent class then Jvm has been confused to whose method should be call at that time this problem is known as
"Due to diamond problen" and JVM has been crashed,

  Was this answer useful?  Yes

kumaravel

  • Nov 22nd, 2012
 

More than one class confused in multiple inheritance and is not supported.

  Was this answer useful?  Yes

Praveen Kumar

  • Dec 13th, 2012
 

Well who said java doesnt support multiple inheritance, Java does support multiple inheritance. Interfaces are used for the same reason. U can implement any number interfaces in your classes however theres a restriction on the number of classes you can extend in your code.

  Was this answer useful?  Yes

pmetha2

  • Jan 3rd, 2013
 

Actually,Multiple Interfaces are inherited but by inherting them,we wont get any defination(its just a blank body).
so, Java supports Multiple Inheritence is a Myth.Its just an illusion.

  Was this answer useful?  Yes

Nitin Kumar Singh

  • Mar 7th, 2013
 

In Java we have the concept of Super() class.
A class may have more than one super class. If there would be Multiple Inheritance then the super() class would be confused which one to refer and so we dont have a concept of Multiple inheritance in Java.

  Was this answer useful?  Yes

Because the JVM can confuse while calling the overriding method defined in both the superclass for a subclass with a same name.For avoiding this we do not use multiple inheritance in java.

  Was this answer useful?  Yes

M.Rajeev

  • Aug 27th, 2014
 

Java does not support multiple inheritance,reason is where the sub class having many number of super classes.
java applications are purely object oriented because of some primitive data types java language is not considered purely object oriented to over come the difficulty by using wraps classes.

  Was this answer useful?  Yes

pratima

  • Oct 15th, 2014
 

If Java supports multiple inheritance then compiler will get confuse which override method will called,because it may be case same methods are using in different different classes .

Code
  1. Class A

  2. {

  3. f1()

  4. }

  5. class B

  6. { f1()

  7. }

  8. class C extends A,B

  9. {

  10.    //object of c here

  11.    //c.f1();

  12. //which method object of C(c) is calling either A or B

  13. //compiler gets confuse here

  14.  

  15. }

  Was this answer useful?  Yes

Ravi

  • Dec 1st, 2014
 

The Reason here is.... In our class (Class C) if I write super inside the constructor it needs to go to immediate super class(B). If my class C extends two classes( B and A), and in my class if i write super to which class it needs to choose? B or C? There comes ambiguity. So Java developers choosen to make us to extend only one super class. So if we declare super it goes to only one class. There would be no confusion. Hope you understand.

  Was this answer useful?  Yes

RaghunathBhairavaJosula

  • Aug 23rd, 2015
 

Java does not support Multiple inheritance by extending multiple classes as in its constructor we call one super class constructor by super(). But still we can achieve the multiple inheritance by implementing N number of 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