Multiple choice

Which of the following statements is true?

  1. It is sometimes good practice to throw an AssertionError explicitly.

  2. Private getter() and setter() methods should not use assertions to verify arguments.

  3. If an AssertionError is thrown in a try-catch block, the finally block will be bypassed.

  4. It is proper to handle assertion statement failures using a catch (AssertionException ae) block.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Option 1 is correct because it is sometimes advisable to thrown an assertion error even if assertions have been disabled. Option 2 is incorrect because it is considered appropriate to check argument values in private methods using assertions. Option 3 is incorrect; finally is never bypassed. Option 4 is incorrect because AssertionErrors should never be handled.