AllInfoHub Logo

AllInfoHub – MCQ Practice

Exception Handling – Multiple Choice Questions (MCQs)

  1. 13. Can a `try` block have multiple `catch` blocks?

    • A. Yes
    • B. No
    • C. Only one
    • D. Only for different types of exceptions
  2. 14. If a `try` block has multiple `catch` blocks, in what order are they checked?

    • A. In the order they are defined
    • B. In reverse order of definition
    • C. Randomly
    • D. Based on the severity of the exception
  3. 15. What happens if an exception is caught by a `catch` block?

    • A. The program continues execution after the `catch` block
    • B. The program terminates
    • C. The `finally` block is skipped
    • D. The exception is re-thrown automatically
  4. 16. What is the purpose of the `finally` block?

    • A. To handle the exception
    • B. To define the code that might throw an exception
    • C. To ensure that certain code is always executed
    • D. To declare a new exception
  5. 17. If an exception occurs in the `try` block and is caught by a `catch` block, is the `finally` block executed?

    • A. Yes
    • B. No
    • C. Only if the exception is handled successfully
    • D. Only if the exception is unchecked
  6. 18. Can a `try` block be nested within another `try` block?

    • A. Yes
    • B. No
    • C. Only if there is a corresponding `catch` block
    • D. Only if the outer `try` has a `finally` block
  7. 19. Can a `try-catch` block be nested within a `finally` block?

    • A. Yes
    • B. No
    • C. Only if the `finally` block might throw an exception
    • D. Only in specific scenarios
  8. 20. What is exception propagation?

    • A. The process of an exception being passed up the call stack if it is not caught in the current method
    • B. The process of handling multiple exceptions in a single `catch` block
    • C. The process of throwing a new exception from a `catch` block
    • D. The process of ignoring an exception
  9. 21. What happens if a method declares that it `throws` a checked exception, but the calling code does not handle it?

    • A. The program terminates
    • B. The compiler will issue an error
    • C. The exception is ignored
    • D. The `finally` block is executed
  10. 22. What is the purpose of creating custom exceptions in Java?

    • A. To handle standard exceptions in a specific way
    • B. To provide more specific information about errors that can occur in an application
    • C. To make the code more complex
    • D. To replace built-in exception classes
  11. 23. How do you create a custom checked exception in Java?

    • A. By extending the `RuntimeException` class
    • B. By extending the `Error` class
    • C. By extending the `Exception` class
    • D. By implementing the `Throwable` interface
  12. 24. How do you create a custom unchecked exception in Java?

    • A. By extending the `Exception` class
    • B. By extending the `Error` class
    • C. By extending the `RuntimeException` class
    • D. By implementing the `Throwable` interface