AllInfoHub Logo

AllInfoHub – MCQ Practice

Exception Handling – Multiple Choice Questions (MCQs)

  1. 1. What is an exception in Java?

    • A. A syntax error in the code
    • B. A logical error in the program
    • C. An event that disrupts the normal flow of the program's execution
    • D. A reserved keyword in Java
  2. 2. Which block is used to enclose the code that might throw an exception?

    • A. try
    • B. catch
    • C. finally
    • D. throw
  3. 3. Which block is used to handle the exception that occurred in the `try` block?

    • A. try
    • B. catch
    • C. finally
    • D. throw
  4. 4. Which block is always executed, regardless of whether an exception occurred or not?

    • A. try
    • B. catch
    • C. finally
    • D. throw
  5. 5. Which keyword is used to explicitly throw an exception?

    • A. try
    • B. catch
    • C. finally
    • D. throw
  6. 6. What is the superclass of all exception classes in Java?

    • A. Throwable
    • B. Exception
    • C. Error
    • D. RuntimeException
  7. 7. What are the two main categories of exceptions in Java?

    • A. Checked and Unchecked
    • B. Syntax and Logical
    • C. Runtime and Compile-time
    • D. Fatal and Non-fatal
  8. 8. What are checked exceptions in Java?

    • A. Exceptions that the compiler forces you to handle (either by catching them or declaring them to be thrown)
    • B. Exceptions that occur during runtime
    • C. Exceptions that are subclasses of `RuntimeException`
    • D. Exceptions that are typically caused by programming errors
  9. 9. What are unchecked exceptions in Java?

    • A. Exceptions that the compiler does not force you to handle
    • B. Exceptions that occur during compile time
    • C. Exceptions that are subclasses of `Exception` but not `RuntimeException`
    • D. Exceptions that are typically related to external resources
  10. 10. Which class is the superclass of all unchecked exceptions in Java?

    • A. Throwable
    • B. Exception
    • C. Error
    • D. RuntimeException
  11. 11. Which of the following is a common checked exception in Java?

    • A. ArrayIndexOutOfBoundsException
    • B. NullPointerException
    • C. IOException
    • D. ArithmeticException
  12. 12. Which of the following is a common unchecked exception in Java?

    • A. FileNotFoundException
    • B. SQLException
    • C. InterruptedException
    • D. NullPointerException