Leading the way in IT testing and certification tools wwwtestkingcom 19 8 9

Leading the way in it testing and certification tools

This preview shows page 20 - 23 out of 143 pages.

Leading the way in IT testing and certification tools, -19 - 8. } 9. output += “1”; 10. } 11. catch(Exception e) { 12. output += “2”; 13. return; 14. } 15. finally { 16. output += “3”; 17. } 18. output += “4”; 19. } 20. 21. public static void main(String args[]) { 22. foo(0); 23. foo(1); 24. 25. } 26. } What is the value of the variable output at line 23? QUESTION NO: 35 Given: 10. public Object m() { 11. Object o = new Float(3.14F); 12. Object [] oa = new Object[1]; 13. oa[0] = o; 14. o = null; 15. return oa[0]; 16. } When is the Float object, created in line 11, eligible for garbage collection?
Image of page 20
310 - 035 Leading the way in IT testing and certification tools, -20 - QUESTION NO: 36 Given: 1. class Base { 2. Base() { System.out.print(“Base”); } 3. } 4. public class Alpha extends Base { 5. public static void main( String[] args ) { 6. new Alpha(); 7. new Base(); 8. } 9. } What is the result? A. Base B. BaseBase C. Compilation fails. D. The code runs with no output. E. An exception is thrown at runtime. Answer: B QUESTION NO: 37 Given: 11. int i = 1,j = -1; 12. switch (i) { 13. case 0, 1:j = 1; 14. case 2: j = 2; 15. default; j = 0; 16. } 17. System.out.println(“j=”+j); What is the result? A. j = -1 B. j = 0 C. j = 1 D. j = 2 E. Compilation fails. Answer: E QUESTION NO: 38
Image of page 21
310 - 035 Given: 1. public class X { 2. public static void main(String [] args) { 3. try { 4. badMethod(); 5. System.out.print(“A”); 6. } 7. catch (Exception ex) { 8. System.out.print(“B”); 9. } 10. finally { 11. System.out.print(“C”); 12. } 13. System.out.print(“D”); 14. } 15. public static void badMethod() {} 17. } What is the result? QUESTION NO: 39 Which two are valid declarations within an interface definition? (Choose two) A.void methoda(); B.public double methoda(); C.public final double methoda(); D.static void methoda(double d1); E.protected void methoda(double d1); Answer: A, B
Image of page 22
Image of page 23

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture