반응형
자격증/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

자격증/OCJP_ExamA2018. 7. 1. 01:12QUESTION 31

Given: interface Foo {} class Alpha implements Foo {} class Beta extends Alpha {} class Delta extends Beta { public static void main( String[] args ) { Beta x = new Beta(); 16. //insert code here } } Which code, inserted at line 16, will cause a java.lang.ClassCastException? A. Alpha a = x; B. Foo f = (Delta)x; C. Foo f = (Alpha)x; D. Beta b = (Beta)(Alpha)x; Solution : B java.lang.ClassCastExce..

자격증/OCJP_ExamA2018. 7. 1. 01:05QUESTION 30

Click the Exhibit button. Which code, inserted at line 14, will allow this class to correctly serialize and deserialize? 1. import java.io.*; 2. public class Foo implements Serializable { 3. public int x, y; 4. public Foo(int x, int y){ 5. this.x = x; this.y = y; 6. } 7. 8. private void writeObject(ObjectOutputStream s) 9. throws IOException{ 10. s.writeInt(x); s.writeInt(y); 11. } 12. 13. priva..

반응형
image