exam questions

Exam 1z0-811 All Questions

View all questions & answers for the 1z0-811 exam

Exam 1z0-811 topic 1 question 43 discussion

Actual exam question from Oracle's 1z0-811
Question #: 43
Topic #: 1
[All 1z0-811 Questions]

Which statement is true about exception handling?

  • A. At least one catch block must accompany a try statement.
  • B. All statements in a try block are executed, even if an exception occurs in the middle of the try block.
  • C. At least one statement in a try block must throw an exception.
  • D. All catch blocks must be ordered from general to most specific.
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
96d6442
4 months ago
None of the provided statements are completely true, but D is closer if reversed. The correct version should be: "All catch blocks must be ordered from most specific to general."
upvoted 1 times
...
MARIAPITA
1 year, 6 months ago
what is the correct answer here? D is incorrect because it is correct the opposite: All catch blocks must be ordered from most specific to most general: a catch for ArithmeticException must come before catch for Exception. A. is incorrect because a try block does not have to be followed by a catch. It's semantically correct, and often necessary to just want a finally block after a try. B. false. When an exception occurs within a try block, it will jump straight out to the catch block (if there isn't a catch block, it will jump into the finally block). And the compiler will deal with the unchecked exception if not within the try block. C false. It is correct to say "might" but not "must throw an exception".
upvoted 2 times
...
CuriosityYen
1 year, 7 months ago
Selected Answer: B
B. All statements in a try block are executed, even if an exception occurs in the middle of the try block. In Java, when an exception occurs within a try block, the remaining statements within that try block are skipped, and the program control immediately transfers to the appropriate catch block. However, it's important to note that the finally block (if present) will still be executed before the control moves to the catch block.
upvoted 1 times
CuriosityYen
1 year, 7 months ago
Sorry, I tried it in IDE and it's A,  In Java, when using a try-catch block, it is required to have at least one catch block accompanying the try block. The catch block is responsible for handling the exception that may occur within the try block. If an exception occurs and there is no corresponding catch block, it will result in a compilation error.
upvoted 2 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago