In the following code, is the object rectangle possible to be destroyed by the garbage collector?
...
Point point = new Point(2,4);
Rectangle rectangle = new Rectangle (point, 20, 20);
point = null;
...
I believe it is rational that both point and rectangle be destroyed by the garbage collector because rectangle references point which is nullified.
An Object becomes eligible for Garbage collection or GC if its not reachable from any live threads or any static refrences – you can say that an object becomes eligible for garbage collection if its all references are null. Also, read up on reference types (strong, weak, soft & phantom).