Demostrate no support of Java to multiple inheritance

Q. Write a program to show that Java does not support multiple inheritance.

Answer:

Multiple Inheritance:
In multiple inheritance, one derive class can extend more than one base class. But java does not support multiple inheritance, because it increases the code complexity.

In this example, we implement the multiple inheritance. But when we run the below code it gives compile time error.

Parent.java

class Child1
{  
   void display()
   {
       System.out.println("class X display method ");
   }  
}  
class Child2
{  
   void display()
   {
       System.out.println("class Y display method ");
   }  
}  
public class Parent extends Child1, Child2
{
    public static void main(String args[])
    {  
        Parent obj=new Parent();  
        obj.display();  
   }  
}


Output:

not support multiple