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(); } }
-
compiler error
-
Hello from a thread!
-
runtime error
-
none of these
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.