Multiple Inheritance

Why multiple inheritance is not applied in Java?

Questions by upendrakumar

Showing Answers 1 - 6 of 6 Answers

Lets take an example


Class A{
public void clear(){

}
}

Class A{
public void clear(){

}
}

Class B extends A{
public void clear(){

}
}

Class C extends A{
public void clear(){

}
}

Now If multiple inhertence is allowed then 

Class D extends B,C{   // 1 - It is not allowed
new D().clear();  // 2
}

In this case when we call statement 2 then it will we confusing to which clear method to be called. This type of problem is known as diamond problem
Thats why Java does not have multiple inhertence

  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