반응형
자격증/OCJP_ExamD2018. 8. 3. 18:08QUESTION 20

QUESTION 20 Given: 1. public class Target { 2. private int i = 0; 3. public int addOne() { 4. return ++i; 5. } 6. } And: 1. public class Client { 2. public static void main(String[] args){ 3. System.out.println(new Target().addOne()); 4. } 5. } Which change can you make to Target without affecting Client? A. Line 4 of class Target can be changed to return i++; B. Line 2 of class Target can be ch..

자격증/OCJP_ExamD2018. 8. 3. 18:01QUESTION 19

QUESTION 19Given a method that must ensure that its parameter is not null: 11. public void someMethod(Object value) { 12. // check for null value ... 20. System.out.println(value.getClass()); 21. } What, inserted at line 12, is the appropriate way to handle a null value? A. assert value == null; B. assert value != null, "value is null"; C. if (value == null) { throw new AssertionException("value..

자격증/OCJP_ExamD2018. 8. 3. 17:53QUESTION 18

QUESTION 18 A team of programmers is involved in reviewing a proposed design for a new utility class. After some discussion, they realize that the current design allows other classes to access methods in the utility class that should be accessible only to methods within the utility class itself. What design issue has the team discovered? A. Tight coupling B. Low cohesion C. High cohesion D. Loos..

자격증/OCJP_ExamD2018. 7. 31. 00:22QUESTION 17

QUESTION 17 Given: import java.io.*; class Animal { Animal() { System.out.print("a"); } } class Dog extends Animal implements Serializable { Dog() { System.out.print("d"); } } public class Beagle extends Dog { } If an instance of class Beagle is created, then Serialized, then deSerialized, what is the result? A. ad B. ada C. add D. adad E. Compilation fails. F. An exception is thrown at runtime...

자격증/OCJP_ExamD2018. 7. 31. 00:18QUESTION 16

QUESTION 16 Given: 11. String test = "This is a test"; 12. String[] tokens = test.split("\s"); 13. System.out.println(tokens.length); What is the result? A. 0 B. 1 C. 4 D. Compilation fails. E. An exception is thrown at runtime. Solution : D Main.java:12: illegal escape character String[] tokens = test.split("\s"); ^ 1 error

자격증/OCJP_ExamD2018. 7. 30. 00:36QUESTION 15

QUESTION 15 Given that c is a reference to a valid java.io.Console object, and: 11. String pw = c.readPassword("%s", "pw: "); 12. System.out.println("got " + pw); 13. String name = c.readLine("%s", "name: "); 14. System.out.println(" got ", name); If the user types fido when prompted for a password, and then responds bob when prompted for a name, what is the result? A. pw: got fido name: bob got..

반응형
image