posted 17 years ago
In the K&B bonus master exam, we have the following question:
Which are true? (Choose all that apply.)
A It's not good practice to place assertions where you think execution where you think execution should never reach.
B It is sometimes appropriate to call getters and setters from assertions.
C Use assertions to verify the arguments of private methods.
D Assertions can be disabled for a particular class.
E Never throw an AssertionError explicitly.
The given answer is C && D. I think E is also right. Could you guys give me an example where we need to throw an AssertionError explicitly?
Thanks,
Best Wishes,<br /> Yeming