Java Objective Questions – Section 1: Exception
Handling
Prepared for Al-Amin Ibrahim
Q1. Which of the following is a checked exception in Java?
A) NullPointerException B) IOException C) ArithmeticException D)
ArrayIndexOutOfBoundsException
Q2. Which keyword is used to manually throw an exception?
A) throw B) throws C) try D) catch
Q3. What happens if an exception is not caught in a program?
A) Program runs normally B) Program crashes and prints a stack trace C) Compiler error occurs D)
Exception is ignored
Q4. Which block always executes whether an exception occurs or not?
A) try B) catch C) throw D) finally
Q5. The superclass of all exception classes is:
A) Object B) Throwable C) Exception D) RuntimeException
Q6. What will be the output of this code?
try { int a = 10 / 0; } catch (ArithmeticException e) { [Link]('Error'); } finally {
[Link]('Done'); }
A) Error B) Done C) Error Done D) Compilation error
Q7. Which keyword is used in a method declaration to indicate that it might throw an
exception?
A) throw B) throws C) try D) catch
Q8. Can we have multiple catch blocks after one try?
A) Yes B) No C) Only if nested D) Only with finally
Q9. What type of exception is ArithmeticException?
A) Checked B) Unchecked C) Custom D) User-defined
Q10. Which exception is thrown when dividing by zero?
A) ArithmeticException B) NumberFormatException C) NullPointerException D)
IllegalArgumentException
Q11. Which of the following cannot be caught by a catch block?
A) Exception B) Error C) Throwable D) RuntimeException
Q12. Which statement about the finally block is true?
A) It executes only if there’s an exception B) It never executes C) It always executes D) It executes
only with checked exceptions
Q13. Which of the following is a valid syntax for multiple catch blocks?
A) One try and one catch only B) Multiple catch blocks after one try C) try after catch D) catch after
finally
Q14. Which class is the root of the Java exception hierarchy?
A) Throwable B) Exception C) Error D) Object
Q15. Which statement is true for throw and throws?
A) Both are the same B) throw is used inside a method, throws in declaration C) throw declares,
throws creates exceptions D) None
Q16. What happens if an exception occurs and there is no matching catch block?
A) Program continues normally B) Program terminates abnormally C) Compiler error D) Exception
ignored
Q17. Can we catch more than one type of exception in a single catch?
A) Yes, using multi-catch (|) B) No, never C) Only in Java 6 D) Only if all are RuntimeExceptions
Q18. Which of these is an unchecked exception?
A) IOException B) SQLException C) NullPointerException D) FileNotFoundException
Q19. What is the use of the try block?
A) To declare exceptions B) To test a block of code for errors C) To handle exceptions D) To stop
exceptions
Q20. Which of these exceptions is thrown when you access an array with an invalid index?
A) ArrayIndexOutOfBoundsException B) IllegalArgumentException C) NullPointerException D)
IndexError
Answer Key – Exception Handling
Q1 → B
Q2 → A
Q3 → B
Q4 → D
Q5 → B
Q6 → C
Q7 → B
Q8 → A
Q9 → B
Q10 → A
Q11 → B
Q12 → C
Q13 → B
Q14 → A
Q15 → B
Q16 → B
Q17 → A
Q18 → C
Q19 → B
Q20 → A