class Base {
public final void show() {
System.out.println("Base::show() called");
}
}
class Derived extends Base {
public void show() {
System.out.println("Derived::show() called");
}
}
public class Main {
public static void main(String[] args) {
Base b = new Derived();;
b.show();
}
}
(A)派生:: show()被调用
(B) Base :: show()被调用
(C)编译器错误
(D)例外答案: (C)
说明:编译器错误:“派生”中的show()无法覆盖Base中的show()
这个问题的测验