Which two code fragments will execute the method doStuff() in a separate thread? (Choose two.)

Which two code fragments will execute the method doStuff() in a separate thread? (Choose two.)

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() { doStuff(); }
}).run();

F.
new Thread(new Runnable() {
public void run() { doStuff(); }
}).start();

Explanation:



Leave a Reply 2

Your email address will not be published. Required fields are marked *


Gowtham

Gowtham

U can start a Thread by using “start()” method