A good answer might be:
String alpha = "Dempster Dumpster"; String beta = alpha; alpha = null;
|
Not Garbage
This time, the object does not become garbage. This is because in the second statement a reference to the object is saved in a second variable, beta. Now when, in the third statement, alpha is set to null, there is still a reference to the object. There can be many copies of the reference to an object. Only when there is no reference to an object anywhere does the object become garbage. |
QUESTION 6:(Review:) How can you determine what an object of a particular class can do? Click Here after you have answered the question |