Exception Handling – Multiple Choice Questions (MCQs)
-
-
14. If a `try` block has multiple `catch` blocks, in what order are they checked?
-
15. What happens if an exception is caught by a `catch` block?
-
16. What is the purpose of the `finally` block?
-
17. If an exception occurs in the `try` block and is caught by a `catch` block, is the `finally` block executed?
-
18. Can a `try` block be nested within another `try` block?
-
19. Can a `try-catch` block be nested within a `finally` block?
-
20. What is exception propagation?
-
21. What happens if a method declares that it `throws` a checked exception, but the calling code does not handle it?
-
22. What is the purpose of creating custom exceptions in Java?
-
23. How do you create a custom checked exception in Java?
-
24. How do you create a custom unchecked exception in Java?