Oracle
1Z0-851 · Question #53
Given: public class TestOne implements Runnable { public static void main (String[] args) throws Exception { Thread t = new Thread(new TestOne()); t.start(); System.out.print("Started"); join()…
The correct answer is E. The code executes and prints "Started0123Complete". See the full explanation below for the reasoning.
Question
Given: public class TestOne implements Runnable { public static void main (String[] args) throws Exception { Thread t = new Thread(new TestOne()); t.start(); System.out.print("Started"); join(); System.out.print("Complete"); } public void run() { for (int i = 0; i < 4; i++) { System.out.print(i); } } } What can be a result?
Options
- ACompilation fails.
- BAn exception is thrown at runtime.
- CThe code executes and prints "StartedComplete".
- DThe code executes and prints "StartedComplete0123".
- EThe code executes and prints "Started0123Complete".
How the community answered
(26 responses)- B4% (1)
- C4% (1)
- D8% (2)
- E85% (22)
Community Discussion
No community discussion yet for this question.