单项选择题

11. public class Test { 
12. public void foo() { 
13. assert false; 
14. assert false; 
15. } 
16. public void bar(){ 
17. while(true){ 
18. assert false; 
19. } 
20. assert false; 
21. } 
22. } 
What causes compilation to fail?()  

A. Line 13
B. Line 14
C. Line 18
D. Line 20


您可能感兴趣的试卷

你可能感兴趣的试题

3.单项选择题

1. public class A { 
2. void A() { 
3. System.out.println(“Class A”); 
4. } 
5. public static void main(String[] args) { 
6. new A(); 
7. } 
8. } 
What is the result?()  

A. Class A
B. Compilation fails.
C. An exception is thrown at line 2.
D. An exception is thrown at line 6.
E. The code executes with no output.

8.多项选择题

public class X { 
public X aMethod() { return this;} 
} 
public class Y extends X { 
} 
Which two methods can be added to the definition of class Y?()

A. public void aMethod() {}
B. private void aMethod() {}
C. public void aMethod(String s) {}
D. private Y aMethod() { return null; }
E. public X aMethod() { return new Y(); }

9.单项选择题Which fragment is an example of inappropriate use of assertions? ()

A. assert (!(map.contains(x))); map.add(x);
B. if (x > 0){}else { assert (x==0); }
C. public void aMethod(int x) { assert (x > 0); }
D. assert (invariantCondition()); return retval;
E. switch (x) { case 1: break; case 2: creak; default: assert (x == 0);

10.单项选择题

int i = 1,j = 10; 
do{ 
if (i>j) { 
continue; 
} 
j--; 
} while (++i <6); 
System.out.println(“i = “ +i+” and j = “+j); 
What is the result?()  

A. i = 6 and j = 5
B. i = 5 and j = 5
C. i = 6 and j = 4
D. i = 5 and j = 6
E. i = 6 and j = 6