Welcome Guest | Sign in | Register
Threads - Discussion Page For Q.2944 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Threads > Questions and Answers

Q:  Which two code fragments will execute the method doStuff() in a separate thread? (Choose two.)
A. new Thread() {
public void run() { doStuff(); }
};

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

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

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

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

Answer and Explanation

Answer:new Thread() {
public void run() { doStuff(); }
}.start();


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

Explanation:
There is no explanation...

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.