class A{
A(int i){

}
}
class B extends A{

}
A、Compile-time error at 5. 
B、Compile-time error at 1. 
C、The compiler attempts to create a default constructor for class B. 
D、The compiler attempts to create a default constructor for class A.能说说为什么么?

解决方案 »

  1.   

    你的子类中没有显示调用父类的构造方法,你这个B类就会调用父类默认的“可访问的无参的构造方法”。由于你的A类没有这个方法。所以直接报错。选D。
      

  2.   

    手误 选A。
    C不对吧 B extends A{ } 这已经报错了。 如果是“attempts to create”即试图创建也肯定先创建父类对象,怎么说都不能能直接创建B。
      

  3.   

    手误 选A。
    C不对吧 B extends A{ } 这已经报错了。 如果是“attempts to create”即试图创建也肯定先创建父类对象,怎么说都不能能直接创建B。这个default constructor我理解有误了,我以为是编译器自动改错提供的构造函数。答案应该是A
      

  4.   

    给A显式创建缺省值构造函数 或者在B中创建创建public B(int i){super(i);}都可以