Bvar is initially initialized to zero but variable initializer is happen after super class object is created
I will give you sequence of execution
1 class loading
2 class initialization first super class and then sub class
3 static inialization or static variable initialization from super then sub class
4 then main of sub invokes
5 then call to super()due to new B()but Bvar initialized to default value
no instance variable initialization happens at this time
5 before A() runs all inastance of A are initialized
doSomething of B is called at that time
Bvar is having only default value of 0
6 then control go to B()
at this time Bvar is happen to 2222 before B() runs
7 in B() printing of BAvr which got value of 2222
I think
you should know this execution process for understaing
then you got why Bvar = 0 in output of program
I hope this may help you
If I am wrong somewhere in explaination please notify me about that
regards
Ninad