which line is an example of an inappropriate use of assertions? | |||||||||||||||||
Answer: Option D
Explanation:
Assert statements should not cause side effects. Line 22 changes the value of z if the assert statement is false.
Option A is fine; a second expression in an assert statement is not required.
Option B is fine because it is perfectly acceptable to call a method with the second expression of an assert statement.
Option C is fine because it is proper to call an assert statement conditionally.
|
Saturday, October 31, 2015
Assert in java
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment