반응형
자격증/OCJP_ExamA2018. 7. 8. 02:03QUESTION 37

QUESTION 37 Given: 01. Float pi = new Float(3.14f); 02. if (pi > 3) { 03. System.out.print("pi is bigger than 3. "); 04. } 05. else { 06. System.out.print("pi is not bigger than 3. "); 07. } 08. finally { 09. System.out.println("Have a nice day."); 10. } What is the result? A. Compilation fails. B. pi is bigger than 3. C. An exception occurs at runtime. D. pi is bigger than 3. Have a nice day. E..

자격증/OCJP_ExamA2018. 7. 8. 01:59QUESTION 36

QUESTION 36 Given: public void method() { A a = new A(); a.method1(); } Which statement is true if a TestException is thrown on line 3 of class B? 1. public class A{ 2. public void method1() { 3. try { 4. B b = new B(); 5. b.method2(); 6. //more code here 7. } catch (TestException te){ 8. throw new RuntimeException(te); 9. } 10. } 11. } 1. public class B{ 2. public void method2() throws TestExce..

자격증/OCJP_ExamA2018. 7. 6. 16:44QUESTION 35

QUESTION 35 Given: public class Donkey2 { public static void main(String[] args) { boolean assertsOn = true; 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_ExamA2018. 7. 6. 16:38QUESTION 34

QUESTION 34 Given: 31. //some code here 32. try { 33. //some code here 34. } catch (NullPointerException e1) { 35. //some code here 36. } finally { 37. //some code here 38. } Under which three circumstances will the code on line 37 be executed? (Choose three.) A. The instance gets garbage collected. B. The code on line 33 throws an exception. C. The code on line 35 throws an exception. D. The co..

자격증/OCJP_ExamA2018. 7. 6. 16:25QUESTION 33

QUESTION 33 Given: 33. try { 34. //some code here 35.} catch (NullPointerException e1) {36. System.out.print("a"); 37. } catch (Exception e2) { 38. System.out.print("b"); 39. } finally {40. System.out.print("c"); 41. } If some sort of exception is thrown at line 34, which output is possible? A. a B. b C. c D. ac E. abc Solution : 나올수 있는 경우의 수 - ac or bc , 예외처리를 수행하고 finally 수행 --> D Plus Imforma..

자격증/OCJP_ExamA2018. 7. 1. 01:28QUESTION 32

Given: public void go() { String o = ""; z: for(int x = 0; x < 3; x++) { for(int y = 0; y < 2; y++) { if(x==1) break; if(x==2 && y==1) break z; o = o + x + y; } } System.out.println(o); } What is the result when the go() method is invoked? A. 00B. 0001 C. 000120 D. 00012021 E. Compilation fails. F. An exception is thrown at runtime. Solution : C

반응형
image