4. 编译运行如下Java代码,输出结果是( D )。
class Base {
public void method(){
System.out.print ("Base method");
}
}
class Child extends Base{
public void methodB(){
System.out.print ("Child methodB");
}
}
class Sample {
public static void main(String[] args) {
Base base = new Child();
base.methodB();
}
}
A. Base method
B. Child methodB
C. Base method Child MethodB
D. 编译错误