Multiple choice technology programming languages

public class TestOne { public static void main (String[] args) throws Exception { Thread.sleep(3000); System.out.println("sleep"); } } What is the result?

  1. Compilation fails.

  2. An exception is thrown at runtime.

  3. The code executes normally and prints "sleep".

  4. The code executes normally, but nothing is print ed.

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

The code compiles and runs successfully. Thread.sleep(3000) is a static method that pauses execution for 3 seconds. The InterruptedException is properly declared in the throws clause, satisfying the compiler. After sleeping, 'sleep' is printed to console. This is standard usage - no compilation errors or runtime exceptions occur.