单选题:Given the following code:
Given the following code:
```Java
public class Test {
String s;
static class Inner {
void testMethod() {
s = "Hello world.";
}
}
public static void main(String[] argv) {
Inner i = new Inner();
i.testMethod();
System.out.println(s);
}
}
```
which one below is correct?@[B](2)
A. It compiles and prints out Hello world.
B. It does not compile because String s in class Test is not static.
C. It does not compile because Inner can not used in the way in main()
D. It compiles and exception raises at running indicates that s has not been initiated.
A.It compiles and prints out Hello world.
B.It does not compile because String s in class Test is not static.
C.It does not compile because Inner can not used in the way in main()
D.It compiles and exception raises at running indicates that s has not been initiated.
答案:B
```Java
public class Test {
String s;
static class Inner {
void testMethod() {
s = "Hello world.";
}
}
public static void main(String[] argv) {
Inner i = new Inner();
i.testMethod();
System.out.println(s);
}
}
```
which one below is correct?@[B](2)
A. It compiles and prints out Hello world.
B. It does not compile because String s in class Test is not static.
C. It does not compile because Inner can not used in the way in main()
D. It compiles and exception raises at running indicates that s has not been initiated.
A.It compiles and prints out Hello world.
B.It does not compile because String s in class Test is not static.
C.It does not compile because Inner can not used in the way in main()
D.It compiles and exception raises at running indicates that s has not been initiated.
答案:B