Why multiple inheritance using classes is disadvantage in java

Showing Answers 1 - 7 of 7 Answers

vvvv

  • Sep 15th, 2005
 

Java does'nt provide multiple inheritance.We can't use like C++.But we can implement multiple inheritance by Interface.We can't say its disadvantage but this is one kind of reusability.

Devidas Sonawane

  • Oct 27th, 2005
 

Like C++ we can't inherite classes in java b'coz variables and methods ambiguity, but by using interface we can overcome that kind of problems easily and safely.

  Was this answer useful?  Yes

chittibabu

  • Apr 7th, 2006
 

First of all class doesnot support multiple inheritance consider class A as superclass class B and C are sub class of A.comment : class cannot extend more than one class think class D extends B and cthe method present in class A,B,C are alike if u call a method in class d we don't know which method we are calling either A or B or c,There accorss Diamond problem and method ambuguity

  Was this answer useful?  Yes

Let's take two classes say class A and class B

class A
{
   doSomething()
{
    //the fun code goes here...
}
}

class B
{
    doSomething()
{
    //serious code goes here
}
}

class C extends A extends B // let's assume for a minute, Java permitted Multiple                                                  Inheritence
{

doSomething();   //which method will it call? the method present in A or B?


}

aleemkh

  • Sep 17th, 2008
 

let us analyze this in real world OO model:

Can a puppy(small dog) extends Cow and Dog? It should be only puppy extends Dog, not both. Puppy(small dog) can't have charectrestics of Cow and Dog

  Was this answer useful?  Yes

A.Bava Bahrudeen

  • Sep 17th, 2011
 

Multiple inheritance does not support in java. Because, ambiguity has been involved in the multiple inheritance in C++ language. That means, a class access the same properties of more than one class. This is ambiguity and it is the main drawback of this concept. Therefore Java developers overcome this concept has been implemented by using interface to avoid ambiguity.

  Was this answer useful?  Yes

sampra

  • Mar 13th, 2012
 

java is build based on concept of no multiple inher to avoid memory usage and ambiguity too

  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.

Answer Question

Click here to Login / Register your free account


 
Send   Reset

 

Related Answered Questions

 

Related Open Questions