Oracle Java SE 8 Programmer II 1z0-809 Question # 44 Topic 5 Discussion

Oracle Java SE 8 Programmer II 1z0-809 Question # 44 Topic 5 Discussion

1z0-809 Exam Topic 5 Question 44 Discussion:
Question #: 44
Topic #: 5

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?


A.

At line n2, insert CyclicBarrier cb = new CyclicBarrier(2, master);


B.

Replace line n1 with class Master extends Thread {


C.

At line n2, insert CyclicBarrier cb = new CyclicBarrier(1, master);


D.

At line n2, insert CyclicBarrier cb = new CyclicBarrier(master);


Get Premium 1z0-809 Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.