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

자격증/OCJP_ExamC2018. 7. 24. 01:20QUESTION 21

QUESTION 21 Click the Exhibit button. class Computation extends Thread { private int num; private boolean isComplete; private int result; public Computation(int num){ this.num = num; } public synchronized void run() { result = num * 2; isComplete = true; notify(); } public synchronized int getResult() { while ( ! isComplete ){ try { wait(); } catch (InterruptedException e) { } } return result; }..

자격증/OCJP_ExamC2018. 7. 24. 01:13QUESTION 20

QUESTION 20 Given: public class PingPong implements Runnable { synchronized void hit(long n) { for (int i = 1; i

자격증/OCJP_ExamC2018. 7. 24. 01:06QUESTION 19

QUESTION 19 Given: foo and bar are public references available to many other threads. foo refers to a Thread and bar is an Object. The thread foo is currently executing bar.wait(). From another thread, what provides the most reliable way to ensure that foo will stop executing wait()? A. foo.notify(); B. bar.notify();C. foo.notifyAll(); D. Thread.notify(); E. bar.notifyAll(); F. Object.notify(); ..

반응형
image