Skip to content
Middle9 views

What happens to an object if one reference is deleted while another remains?

Practice

AI answer

Removing one reference does not destroy an object if another variable or data structure still refers to it. The object remains accessible through the remaining reference. The garbage collector can free it when the object is no longer reachable from the program; the time when it is freed is generally not guaranteed.