Welcome to javaranch. We are a very friendly community and do not have many rules. However, there are a few guidelines that helps you get good answers. It will be nice if you can go through this on how to ask questions in the ranch. Specifically,
Originally posted by sujith delpachithra: Before constructing the B object it calls B's foo(). if it created B object it should call B's constructor first. i am too confused with the result. explain how the results are printed?
No-argument base-class constructors are implicitly called from the extending class' constructor.
It should make sense if you think of B's constructor as:
foo() isn't called before constructing B, but while.