There are a couple of related discussions going on here:
First of all, the GC portion of the exam often trips people up, not because the concepts are that hard but because the wording is so precise and important. So here are a couple of things to keep in mind, and if you have these concepts clearly in your brain it'll help you navigate through the tricky exam questions:
1 - As has been stated in this
thread, you can request that the JVM perform a GC, but it's only a request. There are never any guarantees.
2 - Finalize only runs once per object! If your finalize method has logic that resurrects your object, it's possible for an object to be restored to life, used, and then later become a candidate for GC again. The second time around, finalize will NOT be run.
3 - Be cautious about mock exam questions concerning the GC. In this area of the exam, precise wording is an essential aspect of any question, and most people who make the mock exams don't put their questions through the same level of rigorous analysis that the actual Sun exam questions go through. The GC questions that are pretty safe are those that give code listings and ask you when and if objects become ELIGIBLE for the GC.
4 - While this one isn't on the exam, it's important... don't put any important logic in a finalize method! In fact, we recommend that you don't use finalize at all. I suppose if you're goofing around and want to see when the GC runs you could mess around with finalize, but once again, it's NEVER guaranteed to run.
HTH,
Bert