QUESTION 32 A programmer has an algorithm that requires a java.util.List that provides an efficient implementation of add(0, object), but does NOT need to support quick random access. What supports these requirements? A. java.util.Queue B. java.util.ArrayList C. java.util.LinearList D. java.util.LinkedList Solution : D LinkedList 클래스란??Deque 구현 : Deque 인터페이스는 first와 last로 삽입/삭제하는 것을 모두 지원하기 때문에 ..
QUESTION 31 Given: public class Key { private long id1; private long id2; // class Key methods } A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap. Which two methods should be overridden to assure that Key works correctly as a key? (Choose two.) A. public int hashCode() B. public boolean equals(Key k) C. public int compareTo(Object o) D. public bo..
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..
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)..
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..
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..