Java: Which practice avoids a common mistake with Checked vs Unchecked Exceptions?

Difficulty:

Medium

Questions:

1

Time Limit:

2 minutes

Passing Score:

100%

Question

Which practice avoids a common mistake with Checked vs Unchecked Exceptions?

  1. Ignore the Checked vs Unchecked Exceptions issue and rely on team discipline instead of APIs or contracts.
  2. Silence the Checked vs Unchecked Exceptions problem by using raw types, broad catches, or shared mutable state.
  3. Do not turn every domain problem into a checked exception and burden every API boundary with boilerplate.
  4. Prefer the version of Checked vs Unchecked Exceptions that makes behavior less predictable as long as the code compiles.

Hint

Look for the option that protects correctness instead of hiding the problem.

Answer and rationale

Correct answer: C. Do not turn every domain problem into a checked exception and burden every API boundary with boilerplate.

Do not turn every domain problem into a checked exception and burden every API boundary with boilerplate. This is a common failure mode in real Java code and a frequent interview follow-up.

Track: Java