Given:
1. public class Main { 2. static boolean b; 3. static int x = 0; 4. public static void main(String[] args) { 5. int guess = (int)(Math.random() * 5); 6. if(guess < 0) assert false; 7. assert b = true; 8. assert x = 0; 9. assert x == 0; 10. } } // w w w. j ava2 s .co m
Which are true? (Choose all that apply.)
B and E are correct.
It's considered appropriate, even in public methods, to validate that a code block will not be reached.
Line 8 fails to compile because the first expression in an assert statement must resolve to a boolean value.