This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
There's not actually enough information there to tell - it looks like part of the question is missing. It depends what the s() method of A does. If it doesn't save a reference to b then the B object is eligible for garbage collection after line 5. If it saves a copy of the reference in a then it will be eligible after line 6. But it would be entirely possible for it to do something (like saving a copy in a static reference) that would mean the B object is still not eligible at the end of this code.
Joined: Feb 07, 2012
i think because there are two aliases, refferring to the same object, the two ferences have to be nulled or out of scope for the object to be garbage collected.