nerdexam
Oracle

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.

Handling Exceptions

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)
  • A
    87% (20)
  • B
    9% (2)
  • D
    4% (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`.

AThese are exceptional conditions that a well-written application should anticipate and recoverCorrect

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`.

BThese are exceptional conditions that are external to the application, and that the application

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.

CThese are exceptional conditions that are internal to the application, and that the application

This description is too vague and doesn't capture the key characteristic of checked exceptions requiring compile-time handling or the type hierarchy.

DEvery class that is a subclass of RuntimeException and Error is categorized as checked

This statement is incorrect because subclasses of `RuntimeException` and `Error` are explicitly classified as unchecked exceptions, not checked exceptions.

EEvery class that is a subclass of Exception, excluding RuntimeException and its subclasses, isCorrect

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

#checked exceptions#Exception hierarchy#exception types

Community Discussion

No community discussion yet for this question.

Full 1Z0-803 Practice