class A {
void fun1() {
System.out.println(fun2());
}
int fun2() {
return 123;
}
}
class B extends A {
int fun2() {
return 456;
}
public static void main(String argv[]) {
A a;
B b = new B();
b.fun1() ;
a = b;
a.fun1();
}
}
结果:
456
456