Why we can’t extend more than one class in java?
We can’t extend more than one class in Java. This is so, as Java does not support multiple inheritance because of ambiguity.
Consider the above diagram which shows multiple inheritance as Class D extends both Class B & C. Now lets assume we have a method in Class A and Class B & Class C overrides that method in their own way.
Wait!! here the problem comes – Because D is extending both B & C so if D wants to use the same method which method would be called (the overridden method of B or the overridden method of C).
Henceforth, extension of multiple classes is restricted.