반응형
자격증/OCJP_ExamC2018. 7. 24. 03:19QUESTION 27

QUESTION 27 A programmer must create a generic class MinMax and the type parameter of MinMax must implement Comparable. Which implementation of MinMax will compile? A. class MinMax { E min = null; E max = null; public MinMax() {} public void put(E value) { /* store min or max */ } B. class MinMax { E min = null; E max = null; public MinMax() {} public void put(E value) { /* store min or max */ }..

자격증/OCJP_ExamC2018. 7. 24. 03:16QUESTION 26

QUESTION 26 Given: public class Drink implements Comparable { public String name; public int compareTo(Object o) { return 0; } } and: Drink one = new Drink();Drink two = new Drink();one.name= "Coffee"; two.name= "Tea"; TreeSet set = new TreeSet(); set.add(one); set.add(two); A programmer iterates over the TreeSet and prints the name of each Drink object. What is the result? A. Tea B. Coffee C. C..

QUESTION 25
자격증/OCJP_ExamC2018. 7. 24. 03:10QUESTION 25

QUESTION 25 Given: public class Person { private name; public Person(String name) { this.name = name; } public int hashCode() { return 420; } } Which statement is true? A. The time to find the value from HashMap with a Person key depends on the size of the map. B. Deleting a Person key from a HashMap will delete all map entries for all keys of type Person. C. Inserting a second Person object int..

자격증/OCJP_ExamC2018. 7. 24. 02:54QUESTION 24

QUESTION 24 Given: import java.util.*;public class SortOf { public static void main(String[] args) { ArrayList a = new ArrayList(); a.add(1); a.add(5); a.add(3); Collections.sort(a); a.add(2); Collections.reverse(a); System.out.println(a); } } What is the result? A. [1, 2, 3, 5] B. [2, 1, 3, 5] C. [2, 5, 3, 1] D. [5, 3, 2, 1] E. [1, 3, 5, 2] F. Compilation fails. G. An exception is thrown at run..

자격증/OCJP_ExamC2018. 7. 24. 02:46QUESTION 23

QUESTION 23 Given: public class Person { private String name; public Person(String name) { this.name = name; } public boolean equals(Object o) { if ( ! ( o instanceof Person) ) return false; Person p = (Person) o; return p.name.equals(this.name); } } Which statement is true? A. Compilation fails because the hashCode method is not overridden. B. A HashSet could contain multiple Person objects wit..

자격증/OCJP_ExamC2018. 7. 24. 02:41QUESTION 22

QUESTION 22 Which two code fragments will execute the method doStuff() in a separate thread? (Choose two.) A. new Thread() { public void run() { doStuff(); } }; B. new Thread() { public void start() { doStuff(); } }; C. new Thread() { public void start() { doStuff(); } }.run(); D. new Thread() { public void run() { doStuff(); } }.start(); E. new Thread(new Runnable() { public void run() { doStuf..

반응형
image