QUESTION 33 Given: 1. public static void main(String[] args) { 2. for (int i = 0; i 6) break; 4. } 5. System.out.println(i); 6. } What is the result? A. 6 B. 7 C. 10 D. 11 E. Compilation fails. F. An exception is thrown at runtime. Solution : E plus imformation Main.java:5: cannot find symbol symbol : variable i location: class Breaker System.out.println(i); ^ 1 error
QUESTION 32 Given: 1. public static void main(String[] args) { 2. try { 3. args = null; 4. args[0] = "test"; 5. System.out.println(args[0]); 6. } catch (Exception ex) { 7. System.out.println("Exception"); 8. } catch (NullPointerException npe) { 9. System.out.println("NullPointerException"); 10. } 11. } What is the result? A. test B. Exception C. Compilation fails. D. NullPointerException Solutio..
QUESTION 31 Given: 11. public void go(int x) { 12. assert (x > 0); 13. switch(x) { 14. case 2: ; 15. default: assert false; 16. } 17. } 18. private void go2(int x) { assert (x
QUESTION 30 Given: 1. public class Breaker { 2. static String o = ""; 3. 4. public static void main(String[] args) { 5. z: o = o + 2; 6. for (int x = 3; x
QUESTION 29 Given: 05. class A { 06. void foo() throws Exception { throw new Exception(); } 07. } 08. class SubB2 extends A { 09. void foo() { System.out.println("B "); } 10. } 11. class Tester {12. public static void main(String[] args) { 13. A a = new SubB2(); 14. a.foo(); 15. } 16. } What is the result? A. B B. B, followed by an Exception. C. Compilation fails due to an error on line 9. D. Co..
QUESTION 28 Given: 1. import java.util.*; 2. public class Example { 3. public static void main(String[] args) { 4. // insert code here 5. set.add(new Integer(2)); 6. set.add(new Integer(1)); 7. System.out.println(set); 8. } 9. } Which code, inserted at line 4, guarantees that this program will output [1, 2]? A. Set set = new TreeSet(); B. Set set = new HashSet(); C. Set set = new SortedSet(); D...