Welcome Guest | Sign in | Register
Assertions - Discussion Page For Q.2529 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Assertions > Questions and Answers

Q: Which of the following statements is true?
A. It is sometimes good practice to throw an AssertionError explicitly. B. Private getter() and setter() methods should not use assertions to verify arguments.
C. If an AssertionError is thrown in a try-catch block, the finally block will be bypassed. D. It is proper to handle assertion statement failures using a catch (AssertionException ae) block.

Answer and Explanation

Answer:It is sometimes good practice to throw an AssertionError explicitly.

Explanation:
Option A is correct because it is sometimes advisable to thrown an assertion error even if assertions have been disabled.
Option B is incorrect because it is considered appropriate to check argument values in private methods using assertions.
Option C is incorrect; finally is never bypassed.
Option D is incorrect because AssertionErrors should never be handled.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.