why java not supproting multiple inheritance?

Answers were Sorted based on User's Feedback



why java not supproting multiple inheritance? ..

Answer / aman kr. aggarwal

well as in c++ we have multiple inheritance, but not in java

becz if it is their then having method of same signature
(means same return type, list of paraments, access
specifiers) in 2 different classes and both r extended by
some class AA then while calling method in base class, it
would break down the jvm that to which classes method to be
called.
EX:-
class BB
{
public void a(int x)
{
System.out.println("call from BB");
}
}
class CC
{
public void a(int x)
{
System.out.println("call fro CC");
}
}
class AA extends BB,CC
{
a(5);
}

Is This Answer Correct ?    6 Yes 1 No

why java not supproting multiple inheritance? ..

Answer / tulasi prasad

java does not support multiple inheritance directly because


if we r deriving a sub class from 2 super classes which are
as follows

class A
{
void meth()
{
// substraction;
}
}

class B
{
void meth()
{
// Addition;
}
}

class C extends A,B
{
meth()<--- system get into confusion whether its add
or substarct.
}

Is This Answer Correct ?    2 Yes 0 No

why java not supproting multiple inheritance? ..

Answer / ershad

BCoz of DIAMOND Problem......if A extends B & B extends
A..in this case b wil override the methods of A class..if c
Extends A ..in this case C wil hav Both the properties of
A,B ....if D extends A which properties should D
inherits ..if it B,C propetries Bcoz B are having the same
methods of A & c is having the same methods of A...there
occurs the Diamond problem..

Is This Answer Correct ?    2 Yes 1 No

why java not supproting multiple inheritance? ..

Answer / venkatachalapathy

Java doesn’t provide multiple inheritance (MI), at least
not in the same sense that C++ does. Like
protected, MI seems like a good idea but you know you need
it only when you are face to face with a
certain design problem. Since Java uses a singly-rooted
hierarchy, you’ll probably run into fewer situations in
which MI is necessary. The interface keyword takes care of
combining multiple interfaces.

Is This Answer Correct ?    0 Yes 0 No

why java not supproting multiple inheritance? ..

Answer / xkrebstarx

Why? Because it gets confusing.

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More Core Java Interview Questions

What are the topics in advance java?

0 Answers  


How does final modifier work?

1 Answers   Tech Mahindra,


what are the states associated in the thread? : Java thread

0 Answers  


What is the purpose of using javap?

0 Answers  


What is mean by collections in java?

0 Answers  






Is finalize() similar to a destructor?

0 Answers  


What are basic keywords?

0 Answers  


Is java pass by value or pass by reference?

0 Answers  


There are three interfaces A,B & C. A extends B, B extends C, and C extends A.Is it multiple Inheritance? please anybody help me.....

5 Answers  


write SQL command for table employee where print first name or last name start like "A" and who is working in domain(angular js,java,dotnet)

1 Answers  


which class to use when concatenating strings in a loop.

3 Answers   IBM,


Can main() method in java can return any data?

0 Answers  


Categories