单项选择题
public class SwitchTest {
public static void main(String[] args) {
System.out.println(“value = “ + switchIt(4));
}
public static int switchIt(int x) {
int j = 1;
switch (x) {
case 1: j++;
case 2: j++;
case 3: j++;
case 4: j++;
case 5: j++;
default: j++;
}
return j + x;
}
}
What is the result?()
A. value = 3
B. value = 4
C. value = 5
D. value = 6
E. value = 7
F. value = 8
相关考题
-
单项选择题
int i = 0; for (; i <4; i += 2) { System.out.print(i + “”); } System.out.println(i); What is the result?()
A. 0 2 4
B. 0 2 4 5
C. 0 1 2 3 4
D. Compilation fails.
E. An exception is thrown at runtime. -
单项选择题
1.classTestSuper{22.TestSuper(inti){}3.}4.classTestSubextendsTestSuper{}5.classTestAll{6.publicstaticvoidmain(String[]args){7.newTestSub();8.}9.}Whichistrue?()
A. Compilation fails.
B. The code runs without exception.
C. An exception is thrown at line 7.
D. An exception is thrown at line 2. -
单项选择题
package foo; import java.util.Vector; private class MyVector extends Vector { int i = 1; public MyVector() { i = 2; } } public class MyNewVector extends MyVector { public MyNewVector() { i = 4; } public static void main(String args[]) { MyVector v = new MyNewVector(); } } What is the result?()
A. Compilation succeeds.
B. Compilation fails because of an error at line 5.
C. Compilation fails because of an error at line 6.
D. Compilation fails because of an error at line 14.
E. Compilation fails because of an error at line 17.