Hi Vijaya,
Why is it so bcos in both the cases "j" is declared after i.
The order of declaration is not making any difference in the code
you mentioned. Whenever a class in instantiated, all the instance variables are given thier default values. However, before the initialization is done, you can not assign any existing variable or can not refer any existing reference.
in the second code you posted,
is not assigning variable 'j' to 'i' but it's assigning value '0' returned by method 'giveMeJ()' to 'i'. So it's legal.
hth.