Assertions are used during development and
testing to ensure that your assumptions are correct during code execution. If the test fails, you get an AssertionError with either a default message or one you provided in the assert statement itself.
There are guidelines on where and how to use assertions. Briefly these are (use your study guide for more detail):
1) DO NOT use asserts to validate arguments in a public method
2) Do use asserts to validate arguments on a private method
3) DO NOT use asserts to validate command line arguments
4) Do use asserts (even in public methods) to check for conditions that should never occur
5) DO NOT have any asserts that affect execution by changing values etc.
You also need to know when it it legal to use assertions, and that depends on the version of Java you are compiling against (yes, you need to know this for the SCJP6 exam). Prior to version 1.4, "assert" was not a keyword. So, for example, this was legal in Java 1.3
And this remains legal with Java 1.6
IF you tell it to compile to version 1.3 (although you will get warnings). If you compile to version 1.4 or higher, compilation will fail (as "assert" is now a keyword).
To use assertions you need to enable them at runtime use "-ea" or "-enableassertions", you can also choose to selectively enable assertions based on package and class names.