Why java does not supports multiple inheritance?
Answer Posted / shree
Multiple inheritance eliminated from java because it leads to confusion in many of cases & causes ambiguity.
So to avoid that complexity java does not support multiple inheritance.
/Multiple inheritance program
Class A
{
public void show(){.....}
}
Class B extends A
{
public void show(){.....}
}
Class C extends A{
public void show(){......}
}
Class D extends B,C{ // not supported by java leads to syntax error.
}
Here class D will get confuse which show() method to execute as there are 2 show() methods are available inherited from class B & C.
but to provide functionality of inheritance java provides new concept called INTERFACE.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are java annotations?
Does substring start with 0?
Can we have try without catch block?
What is a method in coding?
What is difference between final and finally in java?
What is a java predicate?
If system.exit (0); is written at the end of the try block, will the finally block still execute?
What is the replace tool?
What is better - 'bit-shift a value' or 'multiply by 2'?
Can we overload destructor in java?
What is the use of put method?
Write a factorial program using recursion in java?
What are the advantages and disadvantages of reference counting in garbage collection?
Is treeset sorted in java?
Can arraylist hold different types java?