Why we achieve multiple interface and why not we achieve multiple inheritance
Dekha jaaye to dono case Mai hum property hi use kartye hai
I have much confusion on this topic please explain this ?
Inheritance Vs interface
In Java, a class cannot extend more than one class. Therefore following is illegal −
Example
public class extends Animal, Mammal{}
However, a class can implement one or more interfaces, which has helped Java get rid of the impossibility of multiple inheritances.
The reason behind this is to prevent ambiguity.
Consider a case where class B extends class A and Class C and both class A and C have the same method display().
Now java compiler cannot decide, which display method it should inherit. To prevent such situation, multiple inheritances is not allowed in java.