1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| public class SubClassTest { public static void main(String[] args) { SubClass s = new SubClass();
CompareA.method1(); s.method2(); s.method3(); } }
class SubClass extends SuperClass implements CompareA,CompareB{ public void method2(){ System.out.println("SubClass:上海"); } public void method3(){ System.out.println("SubClass:深圳"); } public void myMethod(){ method3(); super.method3(); CompareA.super.method3(); CompareB.super.method3(); } }
|