반응형
자격증/OCJP_ExamD2018. 8. 5. 20:54QUESTION 35

QUESTION 35 Given: 1. import java.util.*; 2. 3. public class LetterASort { 4. public static void main(String[] args) { 5. ArrayList strings = new ArrayList(); 6. strings.add("aAaA"); 7. strings.add("AaA"); 8. strings.add("aAa"); 9. strings.add("AAaa"); 10. Collections.sort(strings); 11. for (String s : strings) { 12. System.out.print(s + " "); 13. } 14. } 15. } What is the result? A. Compilation..

자격증/OCJP_ExamD2018. 8. 5. 20:28QUESTION 34

QUESTION 34 Given: 1. import java.util.*; 2. 3. public class Explorer3 { 4. public static void main(String[] args) { 5. TreeSet s = new TreeSet(); 6. TreeSet subs = new TreeSet(); 7. for (int i = 606; i

자격증/OCJP_ExamD2018. 8. 5. 20:21QUESTION 33

QUESTION 33 Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true? (Choose two.) A. The class implements java.lang.Comparable. B. The class implements java.util.Comparator. C. The interface used to implement sorting allows this class to define only one sort sequence. D. The interface used to implement sorti..

자격증/OCJP_ExamD2018. 8. 5. 20:12QUESTION 32

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로 삽입/삭제하는 것을 모두 지원하기 때문에 ..

자격증/OCJP_ExamD2018. 8. 5. 19:41QUESTION 31

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..

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

반응형
image