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.
I don't think so . GC influence efficiency, you just hava 3 objects. GC will no be started.
when you set a object to null, you just tell GC that it can be recovered . but you don't know when the GC will start.it's uncertain.
Generally speaking,when you memory is not enough,GC will start.
you can difine a method like finalize() to monitor the GC.
As you mention in the rest of your quote...you have no way of knowing that GC hasn't started... I also don't think he's literally wondering if it's been GC'd just if it can be....(could be wrong here).
Yunnan Zhou wrote:...when you set a object to null, you just tell GC that it can be recovered . but you don't know when the GC will start.it's uncertain.
Generally speaking,when you memory is not enough,GC will start...
Yes, correct. This kind of questions are more of SCJP question types which ask the *eligibility* for GC incase it's started by the JVM...
Peeyush Bhadola wrote:At line#10: c3 = null. So there is no object present to be marked for GC.
I think you may misunderstand GC....if an object no longer has a reference pointing to it...that's the point at which it is ELIGIBLE to become GC'd (i.e. object = null == ready to be garbage collected). An object = null is still consuming memory until the GC runs....this is due to the fact that the Object still exists it just no longer has a pointer to it to be able to be accessed!