单项选择题

public class Test { 
public static void main(String Args[]) { 
int i =1, j = 0; 
switch(i) { 
case 2: j +=6; 
case 4: j +=1; 
default: j +=2; 
case 0: j +=4; 
} 
System.out.println(“j =” +j); 
} 
} 
What is the result? () 

A. 0
B. 2
C. 4
D. 6
E. 9
F. 13


您可能感兴趣的试卷

你可能感兴趣的试题

2.单项选择题

public void foo( boolean a, boolean b ){ 
if( a ) { 
System.out.println( “A” ); 
} else if ( a && b ) { 
System.out.println( “A&&B” ); 
} else { 17. if ( !b ) { 
System.out.println( “notB” ); 
} else { 
System.out.println( “ELSE” ); 
} 
}
} 
What is correct?()  

A. If a is true and b is true then the output is “A&&B”.
B. If a is true and b is false then the output is “notB”.
C. If a is false and b is true then the output is “ELSE”.
D. If a is false and b is false then the output is “ELSE”.

4.多项选择题

1. public class OuterClass { 
2. private double d1 = 1.0; 
3. // insert code here 
4. } 
Which two are valid if inserted at line 3?()  

A. static class InnerOne { public double methoda() { return d1; } }
B. static class InnerOne { static double methoda() { return d1; } }
C. private class InnerOne { public double methoda() { return d1; } }
D. protected class InnerOne { static double methoda() { return d1; } }
E. public abstract class InnerOne { public abstract double methoda(); }

6.单项选择题

public class Test { 
public static void main(String[] args) { 
int x = 0; 
assert (x > 0) ? “assertion failed” : “assertion passed”; 
System.out.println(“Finished”); 
} 
} 
What is the result?()  

A. finished
B. Compilation fails.
C. An AssertionError is thrown and finished is output.
D. An AssertionError is thrown with the message “assertion failed”.
E. An AssertionError is thrown with the message “assertion passed”.