|
|
Re: Why such behaviour?
|
Posted: Mar 2, 2006 6:29 AM
|
|
Ok, here is what happens.
Call of Child constructor 1. Child's class variables are declared 2. Child constructor calls the constructor of it's parent class 2.1 Parent's class variables are declared 2.2 Parent's constructor calls the constructor of it's parent class, which is Object 2.2.1 //I don't care what happens in Object 2.3 Parent's class variables are initialized 2.4 Parent's constructor is executed 2.4.1 Child's returnVal overrides parent's method, so it is called instead of Parent's returnVal. The class variables in Child are not yet inizialized, just declared, so the value of i is default = 0 3. Child's class variables are initialized 4. Child's returnVal is called, returns 55
|
|