Hybrid Inheritance in java

Hybrid Inheritance: It is a combination of more types of Inheritance. Since java Multiple is not supported directly we can achieve Hybrid Inheritance.

Hybrid Inheritance
Hybrid Inheritance
class C
{
   public void disp()
   {
	System.out.println("C");
   }
}

class A extends C
{
   public void disp()
   {
	System.out.println("A");
   }
}

class B extends C
{
   public void disp()
   {
	System.out.println("B");
   }
	
}

class D extends A
{
   public void disp()
   {
	System.out.println("D");
   }
   public static void main(String args[]){

	D obj = new D();
	obj.disp();
   }
}

Output:
D
Translate »