The Java designers copied a lot of things from C and C++ to make the transition from those languages easy. But they also had a list of things that made C/C++ too hard or error prone that they deliberately left out of Java. Multiple inheritance was in the cut list.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Mar 30, 2006
Although the responses are correct, there is more to the story than that. In the early 1990s, before Java was released, C++ was the dominant OO language for development, and it went through some growing pains. One of the problems compilers ran into was how to properly represent multiple inheritance that a)worked, and b)was relatively efficient. Multiple inheritance, it turned out, wasn't as big a problem inherently as "common" multiple inheritance, in which the two superclasses share a third common class. This resulted in a relationship called, believe it or not, the "diamond of death", because the class diagram for such a relationship formed a diamond, with the "common" base class at the top of the diamond.
The developer of Java (James Gosling) decided to implement much of the functionality of multiple inheritance via a new approach called an interface, eliminating much of the problem. However, it introduced a new problem...since interfaces don't have any code (only method declarations), what do you do if you need to "add" code from two different existing classes? In C++ it's easy...you just inherit from them. In Java, you have to jump through a few more hoops, but it's still possible to do.
In my experience, good design usually mitigates or eliminates the need for multiple inheritance. But every so often a problem arises for which multiple inheritance would actually make more sense that single inheritance.
Joined: Jun 23, 2005
ya wat tom defind is absolutely right.. but the ultimate aim is to avoid name collision..
this is wat the problem with multiple inheritance. and as well u cannot force the java programmers to define different names for the methods. so avoid that too this is being handled. and in interfaces you are supposed to override all the methods. and even in interface also this happens if there are two mtd with same name and overriden..but the thing is if u have same method name in two interfaces then when u override one method then you will be able to define the body to only one of those methods. becoz two methods cant have the same name.so obviously you can define only one method of that name. and the implemented method ie. the overriden method will be called.when u create an object and call it.