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


Please Help Members By Posting Answers For Below Questions

Detail discussions on JVM, memory management and garbage collector.

746


How a string is stored in memory?

775


Why spring singleton is not thread safe?

752


How do you add an arraylist to an array in java?

726


What will happen if static modifier is removed from the signature of the main method?

721


How will you print number in reverse (descending) order in BST.

766


In java, what is the difference between method overloading and method overriding?

807


What is the point of polymorphism java?

750


What are "class access modifiers" in Java?

820


Does java initialize arrays to zero?

713


Can we have this () and super () together?

795


Are strings immutable in java?

733


How can we make a class singleton?

810


What is indexof in java?

738


What modifiers may be used with an inner class that is a member of an outer class in java programming?

767