45.Hybrid inheritance using interface
//Hybrid inheritance using interface
/*
A
|
----------------
| |
B C
| |
--------D--------
*/
interface A
{
void show();
}
interface B
{
void display();
}
class C
{
public void print()
{
System.out.println("This is method of class C");
}
}
class D extends C implements A, B
{
public void show()
{
System.out.println("This is method of interface A");
}
public void display()
{
System.out.println("This is method of interface B");
}
public void msg()
{
System.out.println("This is method of class D");
}
}
class hybrid_inh_intf4
{
public static void main(String[] args) {
D obj = new D();
obj.show();
obj.display();
obj.print();
obj.msg();
}
}
OUTPUT:
This is method of interface A
This is method of interface B
This is method of class C
This is method of class D
Comments
Post a Comment