Hi, I gave an example for the class and object initialisation sequence as follows:
The result is as follows:
which mean Alex's point of view is right.
Hope it helps.
Guoqiao
Originally posted by Alex Sbityakov:
Since the method of class processor is called, it looks for the b in its own class and will still print out 0. The fact that you say static b = 127 in the parent class has no bearing on the child class.
But, if you say static b = 126 in the child class, then it will print 126,126 instead of 0,126. In this example, first the static initializers are executed (we have none), superclass constructor is called, initializers are executed, rest of constructor is run.
So, the superclass runs and calls a child method before b is initialized and the program prints out 0.
Correct me if I'm wrong,
Alex
Guoqiao Sun<br />SCJP2 SCWCD2<br />Creator of <a href="http://www.jiris.com/" target="_blank" rel="nofollow">www.jiris.com</a>, Java resource, mock exam, forum