Multiple choice technology web technology

What is the output for the below code ? class A implements Runnable{ public void run(){ System.out.println(Thread.currentThread().getName()); } } public class Test { public static void main(String... args) { A a = new A(); Thread t = new Thread(a); t.setName("good"); t.start(); } }

  1. good

  2. Compilation succeed but Runtime Exception

  3. null

  4. Compilation fails with an error at line 5

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

The code creates a Thread with Runnable object A, names it 'good', and starts it. The run() method prints the current thread's name using Thread.currentThread().getName(), which returns 'good' since we explicitly set it with t.setName(). No compilation or runtime errors occur.