I will attempt to explain the first one ... The rest you can figure out ...
I changed the class names. The output is: 456 AAA 123 CCC BBB Here is what happens: 1. DerInvTst1 constructor with no args is called. 2. This constructor calls DerInvTst1 constructor that takes an int. arg. 3. Since there is no "this()" call on the first line, the super class's default constructor is called and super class is initialized. 4. This results in printing 456. 5. Next AAA is printed from BasInvTst1 constructor. 6. Now the derived class initialization occurs and "123" is printed. 7. The control is then transfered to the constructor, which prints "CCC" 8. In the end the control is transfered back to DerInvTst1's no-arg constructor and "BBB" is printed. Hope this helps, Brian
posted 18 years ago
it seems that the initialiaze block is not executed before the constructor??? (because the 123 is not the first line of output) can you tell me the exactly time when the initialize block will be executed??? [ April 17, 2002: Message edited by: andy lau ]