No. Multiple inheritance is not possible in Java. Implementing multiple interfaces is not inheritance at all. In inheritance,we get the functionalities whereas by implementing multiple interfaces,we provide the functionalities.
من قبل
Javed Khan , Senior Programmer Analyst , Barclays Technology
Java does support Multiple interface inheritance. Which means behavior can be inherited from multiple interfaces but one has to provide implementation of that behavior.
Multiple inheritance is not possible in java..in multiple inheritance we inherit all the method,member of method and class member of two or more class bt using interface it is not necessary that we achieve multiple interface each and every time.following example demonstrate it as...
interface a
{
void a();
void b();
}
interface b
{
void c();
void d();
}
abstract class InterfaceMultipleInheritence implements a,b
{
public static void main(String arr[])
{
}
}
explanation ...we can execute it without getting member of a(),b(),c(),d()....
No. There is no support for multiple inheritance in java.
Reason:
C++ allows multiple inheritance whereas java completely rejects it.You should look into the Diamond Problem this will help you in understanding the concept.
Diamond Problem:
Suppose we have two classes B and C inheriting from A. Assume that B and C are overriding an inherited method and they provide their own implementation. Now D inherits from both B and C doing multiple inheritance. D should inherit that overridden method, which overridden method will be used? Will it be from B or C? Here we have an ambiguity.
Alternate:Multiple Interface
Because interfaces specify only what the class is doing, not how it is doing it.
The problem with multiple inheritance is that two classes may define different ways of doing the same thing, and the subclass can't choose which one to pick.