class Base{
public Base(String s){
System.out.print("B");
}
}
public class Derived extends Base{
public Derived (String s) {
System.out.print("D");
}
public static void main(String[] args){
new Derived("C");
}
}
-
BD
-
DB
-
C
-
编译错误
答案是:编译错误
- 因为创建子类,默认会调用父类的无参构造函数,没有定义