分析运行结果,说明原理 class A {
void fun1() {
System.out.println(fun2());
}
int fun2() {
return 123;
}
}
public class B extends A {
int fun2() {
return 456;
}
public static void main(String args[]) {
B b = new B();
b.fun1();
A a = b;
a.fun1();
}
}
结果是两个456么...
|
|