本帖最后由 杨锦 于 2012-8-6 19:58 编辑
public class Test { public static void main(String[] args) { A a = new B(); //调A的还是调C的?? a.fun1(); B b = new C(); b.fun1(); a = new C(); a.fun1(); } } class A { void fun1() { fun2(); } void fun2() { System.out.println("A"); } } class B extends A { void fun2() { System.out.println("B"); } } class C extends B { void fun1() { super.fun1(); } void fun2() { System.out.println("C"); } }
程序是怎么运行的?? |