Can anybody please explain how does above code print 40?!!! Thanks VEena
Here is the order of exection: 1. Derived constructor is invoked at line 1 2. Derived constructor invokes the constructor of its superclass Base 3. Base constructor invokes addvalue(). However, since addvalue is overridden, it will call the method defined in the calss Derive. 4. In Derive's addvalue, 20 is added to the variable value. value has now changed from 0 to 20. 5. Upon returning from the Base constructor, the Derive constructor calls its addvalue method. 6. A value of 20 is added to the variable value again. value is now 40.