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).

Result: Ambiguity.

Henceforth, extension of multiple classes is restricted.

Uday Ogra

Connect with me at http://facebook.com/tendulkarogra and lets have some healthy discussion :)

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *