This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Multiple inheritance has not been "removed" from Java; Java has never had multiple inheritance. It was never added in the first place. Why was it not included? Because in C++, in particular, it causes so many headaches. Java is designed to be a simple language to use and understand, and multiple inheritance as implemented in a strongly-typed language generally is not.
A Java class can have many different runtime types by implementing many different interfaces. This is one half of the "multiple inheritance equation" --- the one that's important from a design perspective. If you don't understand why this is more important than the other half -- the "inheriting actual code" part -- then you will learn with some experience.
But in any case, a Java class can inherit many types by implementing interfaces. To reuse code from multiple classes, though, you have to use delegation -- i.e., keep a member of another class, and forward method calls to it, rather than trying to extend it.
suppose u have 3 classes.. two super classes classA and classB.. and both has a method which r named as show().. let both the classes have same method name but different defnition..
if suppose u extend both to ur classC which is ur subclass.. then if u create a an object of ur classC obj=new classC(); and say obj.show(); which method will be called?? will it call from classA or classB?? assuming that u r not overriding that show() in ur subclass..it will throw an error.. but java allows u to create same method names in two or more different classes..so there lies the difficulty or the bug which is there in c++.. so if u implement as an interface u r supposed to override.. it becomes mandatory.. then u will obviously call the subclass version.
thus multiple inheritance is not introduced in java.. and this is one of the plus point of java as well.. [ March 20, 2006: Message edited by: vignesh hariharan ]
Multiple inheritance when used tends to complicate ur code a lot and also the fact that all graphs (obtained by multiple inhertance) can be represented by trees (simple or hierarchical inheritance or multilevel inheritance) by implementing a proper design. hence first of all multiple inheritance is not required as a matter of speaking and if u really need it that badly its not totally removed from java. by using interfaces u can get runtime inheritance but the difference being that u dont have a super implementation of the interface methods