Multiple choice technology programming languages

class A extends Thread { public void run() { System.out.print("A"); } } class B { public static void main (String[] args) { A a = new A(); a.start(); a.start(); // 1 } }

  1. Run Time Exception

  2. Compile Error

  3. the code compile and runs fail

  4. None of the above

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

In Java, calling start() on a Thread twice throws IllegalThreadStateException at runtime because a thread cannot be restarted once it has terminated. The start() method checks the thread state and throws an exception if the thread was already started.