Multiple choice general knowledge

public class Worker extends Thread { public void run() { System.out.print("N"); } public static void main(String [] args) { Thread worker = new Worker(); worker.run(); System.out.print("O"); } }

  1. The output is always NO.

  2. The output is always ON.

  3. The output varies and is either NO or ON.

  4. The code does not compile.

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

The code calls worker.run() directly instead of worker.start(). Direct run() calls execute synchronously in the current thread, printing 'N' first, then 'O', resulting in 'NO'. No actual thread spawning occurs, so output is always deterministic.