GeekInterview.com
Series: Subject: Topic:
Question: 524 of 577

why multiple inheritance using classes is disadvantage in java

Asked by: Interview Candidate | Asked on: Sep 12th, 2005
Showing Answers 1 - 7 of 7 Answers
vvvv

Answered On : 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.

Yes  1 User has rated as useful.
  
Login to rate this answer.
Devidas Sonawane

Answered On : 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.

  
Login to rate this answer.
chittibabu

Answered On : 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

  
Login to rate this answer.
hsavinash2001

Answered On : Sep 14th, 2008

View all answers by hsavinash2001

Let's take two classes say class A and class Bclass 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? }

Yes  2 Users have rated as useful.
  
Login to rate this answer.
aleemkh

Answered On : Sep 17th, 2008

View all answers by aleemkh

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

  
Login to rate this answer.
A.Bava Bahrudeen

Answered On : 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.

  
Login to rate this answer.
sampra

Answered On : Mar 13th, 2012

View all answers by sampra

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

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.