When is the object created at line 3 eligible for garbage collection? A It is eligible after line 7. B It is eligible after line 8. C It is eligible after line 9. D It is not eligible for garbage collection in this method.
my answer was d as when the control moves out of the method the object would be eligible for garbage collection and the other thought was after line 9 it is eligible for garbage collection.
but the correct ans is A
SCJP 5.0<br /> <br />"Skills are started with learning and mastered with improvement. Nothing is hereditary except death" BUDDHA...
The Answer is A because the reference variable "tip" of type Object was reassigned to refer to the String object.So now there is no variable referring to the Object created on the first line and obviously its eligible for Garbage collection.