如下程序的输出结果为

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
  • 编译错误

答案是:编译错误java

  • 由于建立子类,默认会调用父类的无参构造函数,没有定义
相关文章
相关标签/搜索