单选题:What will happen when you attempt to compile and run the followi
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
```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