This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
First of all, this code should not compile. Class A doesn't implement interface C. But, assuming that you posted the wrong code, and everything else is correct...
this is how i think this code should work i put it also in the debugger and it also shows the resolt 11 2 7
Well, I highly doubt that... There are no timing issues (shown in the code) related to this application that would make an actual run different from a debugging run.
and then when it goes to the print method suddenly it shows a=7 b=2 c=7
Well, 7 2 7 is correct. And here is why...
In step 6 of your diagram, you have this line as assigning the value of the parameter b to the instance variable a. This is not true. This line assigns the value of the parameter b to the parameter variable a. To do what you want expect in step 6, you need to do this...
That explains why it compiles. None of the other answers changes.
Joined: Feb 01, 2008
so you are saying that in step 6
that i changed the input variable "a"(a variable which exists only in the signature)?? and not this.a??
my next question (presumption) is that in step 5 i made a similar command but here b.a do change although its a=b too because the signature is public B(int b) there is no a there so we change the b.a variable am i correct [ February 17, 2008: Message edited by: donaldth smithts ]
Joined: Oct 13, 2005
Originally posted by donaldth smithts: so you are saying . . . my next question (presumption) is that in step 5 i made a similar command but here b.a do change although its a=b too because the signature is public B(int b) there is no a there so we change the b.a variable am i correct?