Given: 1. class Super { 2. public int i = 0; 3. 4. public Super(String text) { 5. i = 1; 6. } 7. } 8. 9. public class Sub extends Super { 10. public Sub(String text) { 11. i = 2; 12. } 13. 14. public static void main(String args[]) { 15. Sub sub = new Sub("Hello"); 16. System.out.println(sub.i); 17. } 18. } What is the result? A. 0 B. 1 C. 2 D. Compilation fails. Answer: D QUESTION NO: 68 Given: 11. int i = 1,j = 10; 12. do{ 13. if (i>j) { 14. continue; 15. } 16. j--; 17. } while (++i <6); 18. 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 Answer: D QUESTION NO: 69 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); Answer: C QUESTION NO: 70 Given: 1. public class X { 2. public X aMethod() { return this;} 3. } 1. public class Y extends X { 2. 3. } Which two methods can be added to the definition of class Y? (Choose two) 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(); } Answer: C, E QUESTION NO: 71 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("B"); 12. } 13. System.out.print("D"); 14. } 15. public static void badMethod() { 16. throw new Error(); 17. } 18. } What is the result? A. ABCD B. Compilation fails. C. C is printed before exiting with an error message. D. BC is printed before exiting with an error message. E. BCD is printed before exiting with an error message. Answer: C
JAVA DUMPS 13(SCJP)
Posted by gautam at Thursday, December 06, 2007
Subscribe to:
Post Comments (Atom)
3 comments:
A correct answer for 68 is
A. i = 6 and j= 5
Agree with
A correct answer for 68 is
A. i = 6 and j= 5
No this is D
Post a Comment