单选题:What will happen if you try to compile and execute B’s `main()`
What will happen if you try to compile and execute B’s `main()` method? ( ) @[D](2)
```Java
class A {
int i;
A(int i) { this.i = i * 2; }
}
class B extends A {
public static void main(String[] args) {
B b = new B(2);
}
B(int x) {
System.out.println(x);
}
}
```
A. The instance variable i is set to 4
B. The instance variable i is set to 2
C. The instance variable i is set to 0
D. This code will not compile
A.The instance variable i is set to 4
B.The instance variable i is set to 2
C.The instance variable i is set to 0
D.This code will not compile
答案:D
```Java
class A {
int i;
A(int i) { this.i = i * 2; }
}
class B extends A {
public static void main(String[] args) {
B b = new B(2);
}
B(int x) {
System.out.println(x);
}
}
```
A. The instance variable i is set to 4
B. The instance variable i is set to 2
C. The instance variable i is set to 0
D. This code will not compile
A.The instance variable i is set to 4
B.The instance variable i is set to 2
C.The instance variable i is set to 0
D.This code will not compile
答案:D