class Whatever { int i = 2; }
The above statement in C++ will just reserve a
int variable with an initial value of 2.
But in
Java, the above statement reserves a int
variable with a value of 0. After the program
starts, 2 is assigned to i. It is a two-step job.
I got a question like this in JQPlus, and I answered wrong.