Java |继承|问题2

null

class Base {
final public void show() {
System.out.println( "Base::show() called" );
}
}
class Derived extends Base {
public void show() {
System.out.println( "Derived::show() called" );
}
}
class Main {
public static void main(String[] args) {
Base b = new Derived();;
b.show();
}
}


(A) Base::show()已调用 (B) 已调用派生::show() (C) 编译错误 (D) 运行时错误 答复: (C) 说明: 不能重写Final方法。查看编译器错误 在这里 . 这个问题的小测验

© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享