Mike has very well explained ur doubt:
instance variables exist on the heap with default values, 0, null, or false, before the initializers or constructors are executed. The second code fragment obtained the value of i before the initializer was reached, so it got the default value.
All the instance variables are already initialized to values 0 before the execution of initializers or constructors.
In ur second code, the expression
int j = getI();
is reached before i is initialized to 20. Since i is initialized to 0 before, it gets the value of i as 0. So u get the result as 0.
Just change ur code to:
Now u can see the difference