Reputation: 16472
What does the below code do when you instantiate the StudentRegistrar class?
public class StudentRegistrar
{
public StudentRegistrar ();
{
new RecordManager().Initialize();
}
}
Upvotes: 0
Views: 133
Reputation: 9875
It doesn't necessary destroy the RecordManager
immediately. Initialize()
may spawn a new thread which can then hold a reference to the RecordManager
. Since new threads are a garbage collection root, the RecordManager
reference will be reachable from that root and therefore it will not be cleaned up.
It really depends on what Initialize
does!
Upvotes: 4
Reputation: 122381
It creates an instance of RecordManager
, calls the Initialize()
method and then destroys the instance of RecordManager
.
EDIT: Actually it won't compile due to the spurious ;
Upvotes: 1