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

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

Luz5年前 (2021-05-10)题库1088
What will happen when you attempt to compile and run the following code @[D](2)
```Java
public class Hope{
public static void main(String argv[]){
Hope h = new Hope();
}

protected Hope(){
for(int i =0; i <10; i ++){
System.out.println(i);
}
}
}
```
A. Compilation error: Constructors cannot be declared protected
B. Run time error: Constructors cannot be declared protected
C. Compilation and running with output 0 to 10
D. Compilation and running with output 0 to 9




A.Compilation error: Constructors cannot be declared protected
B.Run time error: Constructors cannot be declared protected
C.Compilation and running with output 0 to 10
D.Compilation and running with output 0 to 9


答案:D