Consider the following code:
1. public class MyClass { 2. public static void main(String[] args) { 3. assert args.length == 0; 4 } 5. }
Which of the following conditions must be true in order for the code to throw an AssertionError?
Assume you are using release 5.0. (Choose all that apply.)
-enableassertions
flag or another assertion enabling flag. A, B, D.
The 1.4 compiler only treated assert as a keyword and not an ordinary identifier if the -source 1.4 flag appeared in the command line.
JDK 5.0 does not require a -source flag.
So A is not a requirement.
If the application is not run with assertions explicitly enabled, all assert statements will be ignored.
If the args array does not have exactly zero arguments, no AssertionError will be thrown.