Oracle
1Z0-819 · Question #43
Given: public class Main { public static void main(String[] args) { Thread t1 = new Thread(new MyThread()); Thread t2 = new Thread(new MyThread()); Thread t3 = new Thread(new MyThread())…
The correct answer is A. An IllegalThreadStateException is thrown at run time. See the full explanation below for the reasoning.
Question
Given:
public class Main {
public static void main(String[] args) {
Thread t1 = new Thread(new MyThread());
Thread t2 = new Thread(new MyThread());
Thread t3 = new Thread(new MyThread());
t1.start();
t2.run();
t3.start();
t1.start();
}
}
class MyThread implements Runnable {
public void run() {
System.out.println("Running.");
}
}
Which one is correct?
Options
- AAn IllegalThreadStateException is thrown at run time.
- BThree threads are created.
- CTwo threads execute.
- DFour threads are created.
How the community answered
(31 responses)- A77% (24)
- B6% (2)
- C13% (4)
- D3% (1)
Community Discussion
No community discussion yet for this question.