Question
Which are true?
Choose all that apply.
- A. It is appropriate to use assertions to validate arguments to methods marked public
- B. It is appropriate to catch and handle assertion errors
- C. It is NOT appropriate to use assertions to validate command-line arguments
- D. It is appropriate to use assertions to generate alerts when you reach code that should not be reachable
- E. It is NOT appropriate for assertions to change a program's state
C, D, and E are correct statements.
Note
A is incorrect.
It is acceptable to use assertions to test the arguments of private methods.
B is incorrect.
While assertion errors can be caught, Oracle discourages you from doing so.
PreviousNextRelated