반응형
자격증/OCJP_ExamD2018. 8. 4. 16:42QUESTION 23

QUESTION 23 Given: class Employee { String name; double baseSalary; Employee(String name, double baseSalary) { this.name = name; this.baseSalary = baseSalary; }} public class SalesPerson extends Employee { double commission; public SalesPerson(String name, double baseSalary, double commission) { // insert code here Line 13 }} Which two code fragments, inserted independently at line 13, will comp..

자격증/OCJP_ExamD2018. 8. 4. 16:38QUESTION 22

QUESTION 22 Given: abstract class A { abstract void a1(); void a2() { }} class B extends A { void a1() { } void a2() { }} class C extends B { void c1() { }} And: A x = new B(); C y = new C(); A z = new C(); What are four valid examples of polymorphic method calls? (Choose four.) A. x.a2(); B. z.a2(); C. z.c1(); D. z.a1(); E. y.c1(); F. x.a1(); Solution : ABDF plus imformation C. z.c1(); // Won't..

자격증/OCJP_ExamD2018. 8. 4. 16:26QUESTION 21

QUESTION 21 Given: class Animal { public String noise() { return "peep"; }} class Dog extends Animal { public String noise() { return "bark"; }} class Cat extends Animal { public String noise() { return "meow"; }} ... 30. Animal animal = new Dog(); 31. Cat cat = (Cat)animal; 32. System.out.println(cat.noise()); What is the result? A. peep B. bark C. meow D. Compilation fails. E. An exception is ..

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

반응형
image