Why java does not supports multiple inheritance?
Answer Posted / mahendra kola
Java Does not support multiple inheritance because java is a simple programming language, but here may be we can get ambiguity
The process of getting variable and methods from more then one class to one or more number of sub classes is called as multiple inheritances.
if we write java program like bellow we get ambiguity problem ....
class A
{
public int n=10;
public void m1(){
System.out.println("A class Method");
}
}
class B
{
int n=20;
public void m1(){
System.out.println("B class Method");
}
}
class C extends A,B
{
System.out.println(n);
public static void main(String[] args){
System.out.println("Child Class");
}
}
• Incase of multiple inheritance, if declare the same variables with deferent values and same methods with different with implementation at two super classes then if we access that variables and methods at the respective subclass then which super class variable will be accessed and which super class methods will be accessed is a confusion state.
• Java is a simple programming language, it should not allowed confusion oriented features, due to this reason, java has not allowed multiple inheritances.
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is class array in java?
What is the difference between yielding and sleeping in java programming?
What steps are taken when the OS shifts from one-thread execution to another?
Explain features of interfaces in java?
What are the benefits of operations in java?
What is the access scope of a protected method?
How to create com object in Java?
What is the difference between Grid and Gridbaglayout?
What is static class
What is the difference between array and array list in java?
Is zero a natural number?
Can a final variable be initialized in constructor?
What are the advantages of inner classes?
How transient variable is different from volatile variable?
What is thread safe singleton?