What will happen when you attempt to compile and run the following code?
(Assume that the code is compiled and run with assertions enabled.)
1.public class AssertTest
2.{
3.public static void main(
String args[])
4.{
5.for(int i=0;i <10;i++)
6.{
7.try
8.{
9.assert i%2==0 : i--;
10.System.out.println("Even number : " + i);
11.}
12.catch(AssertionError ae)
13.{
14.System.out.println("Odd number : " + ++i);
15.}
16.}
17.}
18.}
Answer:It will print odd and even numbers from 0 to 9 correctly (0 even and 1 odd).
Why ?