-->
当前位置:首页 > 题库

单选题:What will happen when you attempt to compile and run the followi

Luz5年前 (2021-05-10)题库1159
What will happen when you attempt to compile and run the following code
```Java
class Base {
private Base() { System.out.println(0);}
public Base(int i) {System.out.println(i);}
}

public class Test extends Base {
public Test() {super(1);};
public static void main(String argv[]){
Test t = new Test();
}
}
```
@[D](2)

A. It does not compile, because constructor can not be private
B. It compiles and prints 0
C. It does not compile, because Test can not be constructed with its super constructor been private
D. It compiles and prints 1




A.It does not compile, because constructor can not be private
B.It compiles and prints 0
C.It does not compile, because Test can not be constructed with its super constructor been private
D.It compiles and prints 1


答案:D