Multiple choice technology programming languages

What will be the result of compiling and running the following code? public class MyThread extends Thread { public static void main(String[] args) { new MyThread().start(); } }

  1. Compile-time error

  2. Runtime error

  3. No output

  4. None of these

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

The code compiles fine since MyThread properly extends Thread. Starting a thread without overriding run() causes it to complete immediately with no output. Thread's default run() is empty.

AI explanation

MyThread extends Thread but does not override run(). Thread.start() spawns a new thread of execution which then calls run() — and since run() isn't overridden here, it executes Thread's default run() implementation, which does nothing (no-op) unless a Runnable target was passed to the constructor (it wasn't). So the program compiles fine, runs without exceptions, and simply terminates with no output. There's no compile-time error (valid syntax), no runtime error (nothing throws), so "No output" is correct.