Multiple choice technology programming languages

What will be the output of the following program? package scjp.threadTest; public class Ques01 { public static void main(String[] args) { HelloThread hello = new HelloThread(); hello.start(); } } class MyThread implements Runnable{ @Override public void run() { System.out.println("My thread"); } } class HelloThread extends Thread{ public void start(){ System.out.println("Hello thread"); } public void run(){ Thread thread = new Thread(new MyThread()); thread.start(); } }

  1. The program will output 'Hello Thread' and 'My Thread'.

  2. The program will output 'Hello Thread'.

  3. The program will output 'My Thread' and 'Hello Thread'.

  4. The order of the outputs is not will vary upon execution.

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

HelloThread overrides start() to print 'Hello thread' without calling super.start(), so the run() method never executes as part of thread startup. The code in run() creates a new Thread but that start() call would work normally. However, since run() is never called by the overridden start(), only 'Hello thread' prints.