Exception Handling

1.What will be the output of the following Java program?
public class Test { public static void main (String[] args) { try { } catch (Exception e) { System.out.println ("Exception caught"); } System.out.println ("Program executed successfully"); } }
  • A. Compilation error
  • B. Exception caught
  • C. Program executed successfully
  • D. Runtime error

Program executed successfully

Program executed successfully

2.What is the superclass of all exceptions in Java?
  • A. Throwable
  • B. Exception
  • C. RuntimeException
  • D. Error

Throwable

Throwable

3.Which of the following is NOT a checked exception?
  • A. IOException
  • B. SQLException
  • C. NullPointerException
  • D. FileNotFoundException

NullPointerException

NullPointerException

4.What happens when an exception is not handled in Java?
  • A. The program continues execution normally
  • B. The program terminates abnormally
  • C. The compiler fixes the issue automatically
  • D. The JVM ignores the exception

The program terminates abnormally

The program terminates abnormally

5.Which keyword is used to manually throw an exception?
  • A. catch
  • B. throw
  • C. throws
  • D. final

throw

throw