Hi,
Example from Kathy Sierra & Bert Bates books.
Given the following,
1. public class Test2 {
2. public static int x;
3. public static int foo(int y) {
4. return y * 2;
5. }
6. public static void main(
String [] args) {
7. int z = 5;
8. assert z > 0;
9. assert z > 2: foo(z);
10. if ( z < 7 )
11. assert z > 4;
12. switch (z) {
13. case 4: System.out.println("4 ");
14. case 5: System.out.println("5 ");
15. default: assert z < 10;
16. }
17. if ( z < 10 )
18. assert z > 4: z++;
19. System.out.println(z);
20. }
21. }
which line is an example of an inappropriate use of assertions?
A. Line 8
B. Line 9
C. Line 11
D. Line 15
E. Line 18
The correct answer is only E, line 18. I am agree, but I think that B,line 9 also is an example of an inappropriate use of assertions. Am I wrong? Why?
Thanks.