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."
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".
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.
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
...
...
Log in to ExamTopics
Sign in:
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.
96d6442
4 months agoMARIAPITA
1 year, 6 months agoCuriosityYen
1 year, 7 months agoCuriosityYen
1 year, 7 months ago