Docsity

Hybrid Inheritance in Java programming, Study notes of Object Oriented Programming

Partial preview of the text

Download Hybrid Inheritance in Java programming and more Study notes Object Oriented Programming in PDF only on Docsity!

HYBRID INHERITANCE

By-Ms.Aquilla Afonso

Asst.Professor

St.Xavier’s College,Mapusa-Goa

HYBRID INHERITANCE

A hybrid inheritance is a combination of

more

than one types of inheritance.

For example

when class A and B extends class C &

another

class D extends class A then this is a

hybrid

inheritance, because it is a combination

of single

and hierarchical 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");

HYBRID INHERITANCE

WHAT WILL

THE MAIN

CONTAIN??

public static void main(String

args[])

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

HYBRID INHERITANCE- Example 2 Drink Juice Soda Smoothie SuperDrink Energy boost (Interface)

HYBRID INHERITANCE-Example 3 LaserPower(interf ace) FlyingHero SuperHero Hero

THANK YOU !!!!