Multiple choice technology programming languages

find the output:: public class HelloThread extends Thread { public void run() { System.out.println("Hello from a thread!"); } public static void main(String args[]) { (new HelloThread()).start(); } }

  1. compiler error

  2. Hello from a thread!

  3. runtime error

  4. none of these

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

The code creates a new HelloThread object and calls start(), which spawns a new thread and invokes run(). The run() method prints "Hello from a thread!". This is standard Java threading - the Thread class's start() method creates the thread and calls run() in the new execution context.