This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
What's happening is that a final int initialised on the same line as it is declared is considered a compile time constant. Therefore the compiler is able to work out that the condition on line 5 is always true. Therefore on line 9 i2 is always initialised.
In the first case i1 isn't a constant. So the compiler can't tell whether the if condition is true or not. So i2 might be initialised, but it might not - and the compiler will complain unless it's absolutely sure.
As Jenson says, if you change i1 to 2 in the second case you'll get an error. Now the compiler knows that i2 won't get initialised.
There is no problem with compiler for that question because for local variable compiler never initialize it by default,we have to initialize it before using it. In that question trick associated with constant declaration i.e for final keyword