0

Multiple inheritance is not supported in the case of class because of ambiguity. However, it is supported in case of an interface. why there is no ambiguity when it comes to implementation?

  • 3
    Does this answer your question? [Why is there no multiple inheritance in Java, but implementing multiple interfaces is allowed?](https://stackoverflow.com/questions/2515477/why-is-there-no-multiple-inheritance-in-java-but-implementing-multiple-interfac) – Ashutosh Feb 04 '20 at 17:15

1 Answers1

0

Its because interface just states what methods are there. We need to define how methods will work. And even if you define a method it automatically becomes static(from java 1.8 on wards. defining method body is permitted in an interface).

In multiple inheritance, same function may be defined differently in both the parent class which results in conflict. Thus, Multiple inheritance is not supported.

Vinit Pillai
  • 518
  • 6
  • 17
  • thanks, but even abstract just states what methods are there, why does multiple inheritance not possible with abstract class? – harish babu Feb 04 '20 at 17:36
  • Abstract is again by definition an incomplete class and it can have methods without body but you can also define methods here which is not by default static. Hence same problem can occur if we extend two abstract classes. – Vinit Pillai Feb 04 '20 at 17:48