Multiple choice technology

Given: 1. public class Threads3 implements Runnable { 2. public void run() { 3. System.out.print("running"); 4. } 5. public static void main(String[] args) { 6. Thread t = new Thread(new Threads3()); 7. t.run(); 8. t.run(); 9. t.start(); 10. } 11. } What is the result?

  1. Compilation fails.

  2. An exception is thrown at runtime.

  3. The code executes and prints "running".

  4. The code executes and prints "runningrunning".

  5. The code executes and prints "runningrunningrunning".

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

t.run() calls the method directly in the main thread (twice), printing 'running' each time. t.start() creates a new thread that also prints 'running'. Total: 3 'running' prints concatenated as 'runningrunningrunning'.