Hi Thanku for the replies Below is code from K&B book i thought the answer could be 28 99 420 28 but the answer is 28 99 420 99 how it is taking 99 instead of 28 can anyone expalin me clearly.. how the shadowing variable concept is involved here. Thanks in advance
changeIt() is passing the refference of Bar object.So its(passed obect's state) state is changed to 99.Then ,new bar object is assigend to this local refferece variable.Making changes (assigning 420)in this new bar object's state won't affect the called refference Object's state.So after completion of changeIt() method ,Bar object is barNum value is 99.