Interview Question
Country: United States
The problem with multiple inheritance is that: two classes may have different function definition but same function declaration, ie same what to do but different how to do it.
The subclass gets confused in picking the function.
Interfaces specify only what the class is doing, not how it is doing it.
Quoting from Kate Serrias SCJP /OCJP book :
- acJavaFreak August 17, 2013This issue can lead to a scenario known as the "Deadly Diamond of Death," because of the shape of the class diagram that can be created in a multiple inheritance design. The diamond is formed when classes B and C both extend A, and both B and C inherit a method from A. If class D extends both B and C, and both B and C have overridden the method in A, class D has, in theory, inherited two different implementations of the same method. Drawn as a class diagram, the shape of the four classes looks like a diamond."
Hence it was avoided in Java