Hello,
there is no problem of "forward referecing" (by the way, i think
this kind of problem doesn't exist in
java), because the instance
variables definition lines :
private int i = giveMeJ();
private int j = 10;
are in fact executed after the call to the super() constructor.
Here , there is no constructor, so you got the default constructor, that
is to say :
public AQuestion() {
super();
}
You also have to remember that instance variables always have default values, they are :
* 0 for numeric types
* null for reference types
So with the instance variables definition lines, we get :
public AQuestion() {
super();
i = giveMeJ();
j = 10;
}
And knowing that the initial values of j is 0, you have the full explanation about this code spinnet.
Hope it helps.
Gilles
Remark : if you switch the definition lines order, you'll get '10' printed,
which makes sense, because the initialisation instructions are processed in
the definition order.