Oracle
1Z0-809 · Question #51
1Z0-809 Question #51: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #51. The question stem and answer options stay visible for context.
Question
Given:
class Worker extends Thread {
CyclicBarrier cb;
public Worker (CyclicBarrier cb) { this.cb = cb; }
public void run () {
try {
cb.await();
System.out.println ("Worker...");
} catch (Exception ex) { }
}
}
class Master implements Runnable { //line n1
public void run () {
System.out.println ("Master...");
}
}
and the code fragment:
Master master = new Master();
//line n2
Worker worker = new Worker (cb);
worker.start();
You have been asked to ensure that the run methods of both the Worker and Master classes are executed. Which modification meets the requirement?
Options
- AAt line n2, insert CyclicBarrier cb = new CyclicBarrier(2, master);
- BReplace line n1 with class Master extends Thread { }
- CAt line n2, insert CyclicBarrier cb = new CyclicBarrier(1, master);
- DAt line n2, insert CyclicBarrier cb = new CyclicBarrier(master);
Unlock 1Z0-809 to see the answer
You've previewed enough free 1Z0-809 questions. Unlock 1Z0-809 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.