Multiple choice technology programming languages

What is the output for the below code ? public class Test extends Thread{ public static void main(String argv[]){ Test b = new Test(); b.start(); } public void run(){ System.out.println("Running"); } }

  1. Compilation clean and run but no output

  2. Compilation and run with the output "Running"

  3. Compile time error with complaint of no Thread import

  4. Compile time error with complaint of no access to Thread package

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

When start() is called on a Thread, it invokes the run() method in a new thread of execution. The Test class extends Thread and overrides run() to print "Running". When main() calls b.start(), the JVM spawns a new thread and executes run(), which outputs "Running" to the console. Options A and D are incorrect because Thread is in java.lang which is auto-imported. Option C is wrong - no explicit import is needed for Thread.