1Z0-803 · Question #148
Which two statement correctly describe checked exception?
The correct answer is A. These are exceptional conditions that a well-written application should anticipate and recover E. Every class that is a subclass of Exception, excluding RuntimeException and its subclasses, is. This question asks to identify two correct descriptions of checked exceptions in Java, which are conditions an application should anticipate and are subclasses of Exception but not RuntimeException or Error.
Question
Which two statement correctly describe checked exception?
Options
- AThese are exceptional conditions that a well-written application should anticipate and recover
- BThese are exceptional conditions that are external to the application, and that the application
- CThese are exceptional conditions that are internal to the application, and that the application
- DEvery class that is a subclass of RuntimeException and Error is categorized as checked
- EEvery class that is a subclass of Exception, excluding RuntimeException and its subclasses, is
How the community answered
(23 responses)- A87% (20)
- B9% (2)
- D4% (1)
Why each option
This question asks to identify two correct descriptions of checked exceptions in Java, which are conditions an application should anticipate and are subclasses of `Exception` but not `RuntimeException` or `Error`.
Checked exceptions represent conditions that a robust application should foresee and include logic to either handle or gracefully recover from, such as `IOException` or `SQLException`.
While some exceptional conditions might be external (e.g., file not found), the description "external to the application" is not the defining characteristic of a checked exception; rather, it's about the requirement for compile-time handling.
This description is too vague and doesn't capture the key characteristic of checked exceptions requiring compile-time handling or the type hierarchy.
This statement is incorrect because subclasses of `RuntimeException` and `Error` are explicitly classified as unchecked exceptions, not checked exceptions.
In Java, checked exceptions are defined as any class that directly or indirectly extends `java.lang.Exception`, with the specific exclusion of `RuntimeException` and its descendant classes, as well as `Error` and its descendants.
Concept tested: Java checked exceptions definition
Source: https://docs.oracle.com/javase/tutorial/essential/exceptions/definition.html
Topics
Community Discussion
No community discussion yet for this question.