Menu

why Java does not support multiple inheritance

Java does not support multiple inheritance because Java does not want any ambiguity and confusion in the code.

Look here how:
Suppose we have a class A which has two methods method1() and method2(). Now another class B inherit the class A and given the definition for both method1 and method2. the another class C inherit class A and B at this point Java will get confused when we give definition for any method in class C. Here the confusion will be that Java don't know exactly from which class we are going to inherit this method either super class class A or class B, since in both the classes we have the method1 and method2.

This is the reason because of that  Java does not support multiple inheritance.


Java Tutorial for beginner 

No comments:

Post a Comment