1 package test2; 2 3 interface Inherit1 { foo1()4 void foo1(); 5 } 6 7 interface Inherit2 extends Inherit1 { foo2()8 void foo2(); 9 } 10 11 abstract class Inherit3 implements Inherit2 { foo3()12 abstract void foo3(); 13 } 14 15 public class Inherit extends Inherit3 { foo1()16 public void foo1() { System.out.println("foo1"); } foo2()17 public void foo2() { System.out.println("foo2"); } foo3()18 public void foo3() { System.out.println("foo3"); } 19 main(String args[])20 public static void main(String args[]) { 21 Inherit i = new Inherit(); 22 Inherit2 i2 = i; 23 i.foo2(); 24 i2.foo1(); 25 } 26 } 27