Register now or log in to join your professional community.
Strictly speaking java does not support multiple inheritance. One java class can only extends one class only. nevertheless you can implement as many interfaces as you wish. If you have a special case where you need to use multiple extends this means tahat your model is not solid enough. If you need any help let me know
Java does not support multiple inheritance.But Java support multiple interface inheritance.
An interface is a blueprint of a class.If a class implements multiple interfaces or an inteface extends multiple interfaces known as multiple interface inheritance.
Simple Eg:
public interface A
{
public String a='A";
}
public interface B
{
public String b="B";
}
public interface C
{
public String c="C";
}
public class D implements A,B,C
{
public static void main(String[] args)
{
String v1=a;
String v2=b;
String v3=c;
System.out.println("Variable a:" +v1);
System.out.println("Variable b:" +v2);
System.out.println("Variable c:" +v3);
}
}
NO.
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.
http://www.javaworld.com/article/2077394/core-java/why-not-multiple-inheritance.html
More technically speaking java doesnt support multiple inheritance coz is more thre ther two object are present at same priority then this would become a state of ambiguity for jvm to select which one of them ,if they have comman data ,and interfaces also seem to be implementing multiple inheritance but they are not following multiple inheritance in any way,
Whenever you find yourself asking why Java has or does not have some feature, consider the design goals behind the Java language.
The reasons for omitting multiple inheritance from the Java language mostly stem from the "simple, object oriented, and familiar" goal.
hey java doesn't support multiple inheritence in real.but you can done it by extends/implements the interface that can help to get multiple inheritence.this is the reason why this feature is more strong in terms of core java.
no java dos't support is's support onle multilevel inheritance