Vinay Dinakar wrote:what i can see from this example
is that, line1 creates one object in heap ("abc") and in line 2, "def" goes to string constant pool and sb (line 1 's object) value gets modified. so total 2 objects. line 3 does not have any effect.
Vinay Dinakar wrote:Arent these string literal also objects ? then how 3 objects gets created, it should be only one right. if it is 3 objects, then whats the difference between string and stringbuffer !!! ?
curve karve wrote:
hey i understood....its like when Base Class constructor is called..it gives a call to derived class constructor ...and again when derived calss constructor is called the same method is executed so..values when methods are not static will be 20+20=40;
when static methods are present since static methods are not overriden..when Base constructor is called it calls method from its class itself which prints value=10 first ..when Derived constructor is called static method of this class is executed ..then value becomes 10+20=30...
m i right???