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.
You are correct, R is in a different heap than A & B. R's reference to A is nothing but a Stub. Hence in side code, when R passes a reference of A to anybody it is actually passing the copy of the stub. And that is OK. If R passes a copy of A's stub to B, then B can call methods or do other stuff on A as an remote object (though they are in the same heap). Option (A) says that R Can not pass a reference of A to B (if fact it can) hence A is not correct.
Option (B) says that A can not pass it’s reference for B to R, yes it can not. Because A & B are LOCAL and they are not dealing with stubs they are dealing with actual references. Those references do not have any value to R being in a separate heap. Hence B is correct.
Let me know if you have any different opinion.
Joined: Jun 10, 2004
Hi Amitava Basu, Thanks for your clarificatio.
when R passes a reference of A to anybody it is actually passing the copy of the stub. And that is OK.
The above clarification you have given was the point I was missing in my understanding, when R passes a reference of A I was assuming the actual object reference. Thanks for you clarification. BTW, this solution will satisfy if we're assuiming this one.