给定以下代码块:
public class Trial {
public static void main (String[] args){
B obj = new B();
obj.doMethod(); #prints "From A".
}
}
class A {
private void method(){System.out.print("from A");}
public void doMethod(){method();}
}
class B extends A {
public void method(){System.out.print("from B");}
public void doMethod(){super.doMethod();}
}
事实证明,调用了类 A 中的 method()。为什么是这样?