wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Garbage collection and refrences Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Garbage collection and refrences" Watch "Garbage collection and refrences" New topic
Author

Garbage collection and refrences

Miles Green
Greenhorn

Joined: Mar 26, 2004
Posts: 4
Question 13 of chap 17 of K&B is:
Which statement is true?
...
C. If an object can be accessed from a live thread, it can't be garbage collected.
... (other answers not relevant)
The answer is obviously C... but is that statement actually true?
The book explains breifly strong, soft, weak, and phantom refrences, saying that only strong refrences are not garbage collected at some point, but if you have a weak refrence to an object, you have access to the object, but it can be garbage collected, proving the true statement false.
Is my logic correct? (I know this is not on the exam, but you cant say the statement is true if it isn't)
fethi makhlouf
Ranch Hand

Joined: Feb 16, 2004
Posts: 50
Hi Green,
I think you are right! but here they try to say , implicitly, that object is strongly referenced, may be Kate and Bert have more!


SCJP 1.4
Sanjay Gandham
Greenhorn

Joined: Mar 26, 2004
Posts: 8
Miles,
Here is my take on it. The book states that unless told explicitly otherwise, accessibility and/or refrence usually refer(s) to strong references. As objects with strong references cannot be collected, the answer is correct. The book also states that you do not need to know the advanced management model for the exam, so at least in the context of the exam, the question and answer are correct.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Sanjay Gandham:
The book also states that you do not need to know the advanced management model for the exam...

Exactly. Although there is a model for advanced reference control, you need not know it for the SCJP exam. Within the context of the exam, you can assume that any reference is a "strong" reference.
Corey


SCJP Tipline, etc.
 
GeeCON Prague 2014
 
subject: Garbage collection and refrences