Java Program using hybrid inheritance
In this program, You will learn how to implement hybrid inheritance in java.
interface A { }
interface B { }
interface C extends B { }
class Test extends A implements C { }
Example: How to implement hybrid inheritance in java.
interface B {
int x = 20;
}
interface C extends B {
int y = 30;
}
class A {
int z = 10;
}
class Main extends A implements C {
void display() {
System.out.println("The x value is :" + x);
System.out.println("The y value is :" + y);
System.out.println("The z value is :" + z);
}
public static void main(String args[]) {
Main t = new Main();
t.display();
}
}
Output:
The x value is :20
The y value is :30
The z value is :10