Found this reply by Tony Sintes (from Java World) :-
Whenever you find yourself asking why Java has or does not have some feature, consider the design goals behind the Java language. With that in mind, I started my search by skimming through "The Java Language Environment" by James Gosling and Henry McGilton (Sun Microsystems), a white paper published in May 1996 that explains some of the reasoning behind Java's design.
As the white paper states, the Java design team strove to make Java:
Simple, object oriented, and familiar
Robust and secure
Architecture neutral and portable
High performance
Interpreted, threaded, and dynamic
The reasons for omitting multiple inheritance from the Java language mostly stem from the "simple, object oriented, and familiar" goal. As a simple language, Java's creators wanted a language that most developers could grasp without extensive training. To that end, they worked to make the language as similar to C++ as possible (familiar) without carrying over C++'s unnecessary complexity (simple).
In the designers' opinion, multiple inheritance causes more problems and confusion than it solves. So they cut multiple inheritance from the language (just as they cut operator overloading). The designers' extensive C++ experience taught them that multiple inheritance just wasn't worth the headache.
Instead, Java's designers chose to allow multiple interface inheritance through the use of interfaces, an idea borrowed from Objective C's protocols. Multiple interface inheritance allows an object to inherit many different method signatures with the caveat that the inheriting object must implement those inherited methods. Multiple interface inheritance still allows an object to inherit methods and to behave polymorphically on those methods. The inheriting object just doesn't get an implementation free ride
Regards, Sam
Above answer was rated as good by the following members: Tarun Wadhwa
RE: why is multiple inheritance not allowed in java?
By not allowing the inheritance of multiple base classes by a single subclass, Java greatly simplifies the inheritance model. Multiple inheritance carries with it several special cases that must be handled. This adds overhead to both the compiler and the run-time system, while providing only marginal benefit for the programmer.
RE: why is multiple inheritance not allowed in java?
In multiple Inheritance,
ex: class A, Class B inherited from Class A, Class C inherited from class A, Class D inherited From Class B,and Class C.
in this Class D have dual copy of the methods ,datamembers defined in Class A, Vertual Function Is there in C++ but,again the pointer are not used in java.
So to avoid this ambiguity, only single chain inheritance is there, not multiple inheritance.
RE: why is multiple inheritance not allowed in java?
Hi ,
Can any one solvethe diamond problem.
Assume there is a super class "Shape", Shape is extended into "Circle" and "Squre". Now I want to create a concrete class "CircleOnSqure" which extends both the Circle and Square. How to implement this functionality in Java.
Hint : Java says Multiple inheritance can be done using Interfaces.
RE: why is multiple inheritance not allowed in java?
Due to the concept of overridding Java doesn't support multiple inheritance.
We have the concept of " Deadly Diamond of Death".
i.e.,
As we have an overridding concept in Java.
We know what overridding is, where the method name including parameters return types should be same.
If mutliple inheritance is provided in java.
eg:
A<- B, A-<C and now B,C<-D
We have a method viz. display() in A, we are overridding that in B and C. If D extends that two classes then if I call the display() then there will be ambiguity. To call which version of display().
As we dont have the concept of virtual functions, what we have in c++.
This is the reason why we dont have multiple inheritance in java.
RE: why is multiple inheritance not allowed in java?
Multiple inheritance is not allowed in java because it may lead to confusion for a programmer and this is against to java language to be a simple(one of the features of OOP's).Eg:class A extends B,C (not allowed in java) class A extends B class C extends A which is nothing but multiple inheritance, it means multiple inheritance can be achieved by repeated use of single inheritance. 2)we can also achieve multiple inheritance by using interfaces.
RE: why is multiple inheritance not allowed in java?
You are saying that if D class is having the dual copy of methods then ambiguity will come, Suppose there is least chance of having dual copy of methods,Is it ok?