adspace


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


Please Help Members By Posting Answers For Below Questions

How to sort array in descending order in java?

990


How to create a base64 decoder in java8?

1133


What is a classloader in java?

1086


What is the difference between break and continue statements?

1121


What is a constructor overloading in java?

1123


Write a program to find the whether a number is an Armstrong number or not?

1095


What is java string pool?

1079


Write a java program to find the route that connects between Red and Green Cells. General Rules for traversal 1. You can traverse from one cell to another vertically, horizontally or diagonally. 2. You cannot traverse through Black cells. 3. There should be only one Red and Green cell and at least one of each should be present. Otherwise the array is invalid. 4. You cannot revisit a cell that you have already traversed. 5. The maze need not be in the same as given in the above example

2661


Explain public static void main(string args[]) in java.

1069


Is minecraft 1.15 out?

1043


explain different ways of using thread? : Java thread

1079


Differentiate between static and non-static methods in java.

1123


Write a program to print count of empty strings in java 8?

1084


What are the differences between heap and stack memory in java?

1134


What do you mean by an interface in java?

1098