Why java Don't Support Multiple interitence
Answer Posted / bhaskar reddy
There is a big reason behind that(java does not support
multiple inheritance). Please go through the following
example.
1. Assume that java is supporting multiple inheritance
class A {
void m1() {
// implement method
}
}
class B {
void m1() {
// implement method
}
}
//As for the assumption (1) the following code will compile
class C extends A,B {
public static void main( String s[]) {
C c = new C();
c.m1();
}
}
Note : In main method i am calling c.m1() method In this
situation which super class m1 method has to call (from A
or B) JVM will confuse.
So our assumtion(1) is wrong .
This is the reason why java does not support multple
inheritance through classes.
Note : This same cocept is applicable for classes.
| Is This Answer Correct ? | 29 Yes | 4 No |
Post New Answer View All Answers
What are the 6 boolean operators?
How to sort numbers in java without array?
What happens when a thread cannot acquire a lock on an object in java programming?
Can a class be private or protected in java?
Explain the difference between map and flatmap stream operation?
What does 0 mean in boolean?
What does the three dot emoji mean?
What is the unit of plancks constant?
What is the difference between superclass and subclass?
How to print an arraylist in java?
What is the purpose of the system class in java?
What is java oops?
what is method reference in java 8?
Can you give names of Container classes?
What is the difference between == and === javascript?