반응형
자격증/OCJP_ExamB2018. 7. 13. 17:53QUESTION 42

QUESTION 42 Given: public class Donkey { public static void main(String[] args) { boolean assertsOn = false; assert (assertsOn) : assertsOn = true; if(assertsOn) { System.out.println("assert is on"); } } } If class Donkey is invoked twice, the first time without assertions enabled, and the second time with assertions enabled, what are the results? A. no output B. no output assert is on C. assert..

자격증/OCJP_ExamB2018. 7. 11. 14:19QUESTION 41

QUESTION 41 Given: public class Test { public enum Dogs {collie, harrier}; public static void main(String [] args) { Dogs myDog = Dogs.collie; switch (myDog) { case collie: System.out.print("collie "); case harrier: System.out.print("harrier "); } } } What is the result? A. collie B. harrier C. Compilation fails. D. collie harrier E. An exception is thrown at runtime. Solution : D plus imformati..

자격증/OCJP_ExamB2018. 7. 11. 14:12QUESTION 40

QUESTION 40 Given: 1. public class Pass2 { 2. public void main(String [] args) { 3. int x = 6; 4. Pass2 p = new Pass2();5. p.doStuff(x); 6. System.out.print(" main x = " + x); 7. } 8. 9. void doStuff(int x) { 10. System.out.print(" doStuff x = " + x++); 11. } 12. } And the command-line invocations: javac Pass2.java java Pass2 5 What is the result? A. Compilation fails. B. An exception is thrown ..

자격증/OCJP_ExamB2018. 7. 11. 14:01QUESTION 39

QUESTION 39 Given classes defined in two different files: 1. package util; 2. public class BitUtils { 3. private static void process(byte[] b) {} 4. } and 1. package app; 2. public class SomeApp { 3. public static void main(String[] args) { 4. byte[] bytes = new byte[256]; 5. // insert code here 6. } 7. } What is required at line 5 in class SomeApp to use the process method of BitUtils? A. proce..

자격증/OCJP_ExamB2018. 7. 11. 00:09QUESTION 38

QUESTION 38 Given: 01. public static void test(String str) { 02. int check = 4; 03. if (check = str.length()) { 04. System.out.print(str.charAt(check -= 1) +", "); 05. } else { 06. System.out.print(str.charAt(0) + ", "); 07. } 08. } and the invocation: test("four"); test("tee"); test("to"); What is the result? A. r, t, t, B. r, e, o, C. Compilation fails. D. An exception is thrown at runtime. So..

자격증/OCJP_ExamB2018. 7. 10. 23:01QUESTION 36

QUESTION 36 Given: class Snoochy { Boochy booch; public Snoochy() { booch = new Boochy(this); } } class Boochy { Snoochy snooch; public Boochy(Snoochy s) { snooch = s; } } And the statements: 21. public static void main(String[] args) { 22. Snoochy snoog = new Snoochy(); 23. snoog = null; 24. // more code here 25. } Which statement is true about the objects referenced by snoog, snooch, and booch..

반응형
image