Java Exceptions- Quiz for Beginners(With Answers & Explanations) total-qa June 13, 2025 June 13, 2025 No Comments on Java Exceptions- Quiz for Beginners(With Answers & Explanations) 1. Which of the following is a checked exception? NullPointerException IOException ArithmeticException ArrayIndexOutOfBoundsException Explanation: Checked exceptions are checked at compile time, and IOException is a classic example. The others are unchecked (runtime) exceptions. 2. What happens if a method throws a checked exception but does not declare it in the method signature or handle it? Program compiles and runs normally Compile-time error occurs Runtime error occurs Exception is ignored Explanation: Java enforces handling of checked exceptions. If not caught or declared using throws, the compiler will throw an error. 3. Which of the following is a runtime exception? ClassNotFoundException NumberFormatException IOException FileNotFoundException Explanation: NumberFormatException are unchecked exceptions, so they occur at runtime. ClassNotFoundException, FileNotFoundException and IOException are checked exceptions. 4. Which keyword is used to manually throw an exception in Java? throw throws try catch Explanation: The throw keyword is used to explicitly throw an exception object. 5. What is the output of the following code? try { int a = 10 / 0; } catch (ArithmeticException e) { System.out.println("Exception caught"); } Compile-time error Runtime error Exception caught Program terminates silently Explanation: Division by zero throws an ArithmeticException, which is caught by the catch block. Loading …