반응형
자격증/OCJP_ExamD2018. 8. 5. 19:36QUESTION 30

QUESTION 30 Given: public class Person { private String name, comment; private int age; public Person(String n, int a, String c) { name = n; age = a; comment = c; } public boolean equals(Object o) { if (!(o instanceof Person)) return false; Person p = (Person) o; return age == p.age && name.equals(p.name); } } What is the appropriate definition of the hashCode method in class Person? A. return s..

자격증/OCJP_ExamD2018. 8. 5. 19:29QUESTION 29

QUESTION 29 Click the Exhibit button. 1. import java.util.*; 2. public class TestSet{ 3. enum Example {ONE, TWO, THREE } 4. public static void main(String[] args) { 5. Collection coll = new ArrayList(); 6. coll.add(Example.THREE); 7. coll.add(Example.THREE); 8. coll.add(Example.THREE); 9. coll.add(Example.TWO); 10. coll.add(Example.TWO); 11. coll.add(Example.ONE); 12. Set set = new HashSet(coll)..

자격증/OCJP_ExamD2018. 8. 5. 19:21QUESTION 28

QUESTION 28 Click the Exhibit button. 1. public class Car { 2. private int wheelCount; 3. private String vin; 4. public Car(String vin){ 5. this.vin = vin; 6. this.wheelCount = 4; 7. } 8. public String drive(){ 9. return "zoom-zoom"; 10. } 11. public String getInfo() { 12. return "VIN: " + vin + " wheels: " + wheelCount; 13. } 14. } And 1. public class MeGo extends Car { 2. public MeGo(String vi..

자격증/OCJP_ExamD2018. 8. 5. 19:13QUESTION 27

QUESTION 27 Which three statements are true? (Choose three.) A. A final method in class X can be abstract if and only if X is abstract. B. A protected method in class X can be overridden by any subclass of X. C. A private static method can be called only within other static methods in class X. D. A non-static public final method in class X can be overridden in any subclass of X. E. A public stat..

자격증/OCJP_ExamD2018. 8. 4. 17:18QUESTION 26

QUESTION 26 Given: class Pizza { java.util.ArrayList toppings; public final void addTopping(String topping) { toppings.add(topping); } public void removeTopping(String topping) { toppings.remove(topping); }} public class PepperoniPizza extends Pizza { public void addTopping(String topping) { System.out.println("Cannot add Toppings"); } public static void main(String[] args) { Pizza pizza = new P..

자격증/OCJP_ExamD2018. 8. 4. 17:03QUESTION 25

QUESTION 25 Given that: Gadget has-a Sprocket and Gadget has-a Spring and Gadget is-a Widget and Widget has-a Sprocket Which two code fragments represent these relationships? (Choose two.) A. class Widget { Sprocket s; } class Gadget extends Widget { Spring s; } B. class Widget { } class Gadget extends Widget { Spring s1; Sprocket s2; } C. class Widget { Sprocket s1; Spring s2; } class Gadget ex..

반응형
image