OCJP 6 Examen 1
![]() |
![]() |
![]() |
Título del Test:![]() OCJP 6 Examen 1 Descripción: Examen de preparacion para certificacion |




Comentarios |
---|
NO HAY REGISTROS |
Give: 10. interface Foo{} 11. class Alpha implements Foo { } 12. class Beta extends Alpha { } 13. class Delta extends Beta { 14. public static void main (Strings[ ] args) 15.. Beta x = new Beta( ); 16. // insert code here 17.} 18.} Which code, inserted at line 16, will cause a java.lang.ClassCastException?. Beta b = (Beta)(Alpha)x;. Foo f = (Delta)x;. Alpha a = x;. Foo f = (Alpha)x;. Give: 11. piblic class Test { 12. public static void main (String [ ] args) { 13. int x = 5; 14. boolean b1 = true; 15. boolean b2 = false; 16. 17. if((x == 4) && !b2) 18. System.out.print("1"); 19. System.out.print("2"); 20. if ((b2 = true) && b1) 21. System.out.print("3"); 22. } 23. } What is the result?. 2 3. 2. An Exceptional is thrown at runtime. Compilation fails. Given: 31. // some code here 32. try { 33. // some code here 34. } catch (SomeException) { 35. // sme code here 36. } finally { 37. // some code here 38. } Under which three circunstances will the code on line 37 be executed (Choose three.). The instamde gets garbage collected. The code on line 33 throws an exception. The code on line 35 throws an exception. The code on line 33 executes successfully. The code on line 31 throws an exception. Given: 10. class Nav { 11. public enum Direction { NORTH, SOUTH, EAST, WEST} 12. } 13. public class Sprite { 14. // insert code here 15. } Which code, inserted at line 14, allows the Sprite class to compile?. Direction d = NORTH;. Nav.Direction d = NORTH;. Nav.Direction d = Nav.Direction.NORTH;. Direction d = Direction.NORTH. Given: 11. public interface Status { 12. /* insert code here */ int MY_VALUE = 10; 13. } Which three are valid on line 12? (Choose three.). abstract. protected. private. static. public. native. final. Which Man class properly represents the relationship "Man has a best friend who is a Dog ". class Man { private BestFriend dog; }. class Man extends Dog { }. class Man { private Dog bestFriend; }. class Man implements Dog { }. Given: 23. Object [ ] myObjects = { 24. new Integer(12), 25. new String("foo"), 26. new Integer(5), 27. new Boolean(true) 28. }; 29. Arrays.sort(myObjects); 30. for(int i = 0; i<myObjects.length; i++) { 31. System.out(myObjects[ i ].toString()); 32. System.out(""); 33. } What is the result?. A ClassCastException occurs in line 29. A ClassCastException occurs in line 31. Compilation fails due to an error in line 23. Compilation fails due to an error in line 29. Given. 10. package com.sun.scjp; 11. public class Geodetics { 12. public static final double DIAMETER = 12756.32; //kilometers 13. } Which two correctly access the DIAMETER member of the Geodetics class? (Choose two.). package com.sun.scjp; public class TerraCarta { public double halfway( ) { return DIAMETER/2.0;} }. import static com.sun.scjp.Geodetics; public class TerraCarta { public double halfway( ) { return DIAMETER/2.0;} }. import static com.sun.scjp.Geodetics.*; public class TerraCarta { public double halfway( ) { return DIAMETER/2.0;} }. import com.sun.scjp.Geodetics; public class TerraCarta { public double halfway( ) { return Geodetics.DIAMETER/2.0;} }. Given: 13. public class Pass { 14. public static void main(String [ ] args) { 15. int x = 5; 16. Pass p = new Pass( ); 17. p.doStuff(x); 18. System.out.print(" main x = " + x); 19. } 20. 21. void doStuff(int x) { 22. System.out.print(" doStuff x = " + x++) 23. } 24. } What is the result?. An exception is thrown at runtime. doStuffx = 6 main x = 6. doStuffx = 6 main x = 5. doStuffx = 5 main x = 6. Compilation fails. doStuffx = 5 main x = 5. Given: 10. public class Bar { 11. static void foo (int...x) { 12. // insert code here 13. } 14. } Which two fragments, inserted independently at line 12, will allow the class to compile? (Chosse two.). while(x.hasNext( )) System.out.oritln(x.next());. for(int z : x) System.out.println(z);. for(int i = 0; i< x.length; i++) System.out.println(x[ i ]);. foreach(x) System.out.println(z);. |