반응형
자격증/OCJP_ExamB2018. 7. 13. 19:14QUESTION 45

QUESTION 45 Given: static class A { void process() throws Exception { throw new Exception(); }} static class B extends A { void process() { System.out.println("B"); }} public static void main(String[] args) { new B().process(); } What is the result? A. B B. The code runs with no output. C. Compilation fails because of an error in line 12. D. Compilation fails because of an error in line 15. E. C..

자격증/OCJP_ExamB2018. 7. 13. 19:03QUESTION 44

QUESTION 44 Given: 1. class TestException extends Exception { } 2. class A { 3. public String sayHello(String name) throws TestException { 4. if(name == null) throw new TestException(); 5. return "Hello " + name; 6. } 7. } 8. public class TestA { 9. public static void main(String[] args) { 10. new A().sayHello("Aiko"); 11. } 12. } Which statement is true? A. Compilation succeeds. B. Class A does..

자격증/OCJP_ExamB2018. 7. 13. 18:09QUESTION 43

QUESTION 43 Given: static void test() throws Error { if (true) throw new AssertionError(); System.out.print("test "); } public static void main(String[] args) { try { test(); } catch (Exception ex) { System.out.print("exception "); } System.out.print("end "); } } What is the result? A. end B. Compilation fails. C. exception end D. exception test end E. A Throwable is thrown by main. F. An Except..

자격증/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 ..

반응형
image