Given the code fragment:
Which statement is true?
A. After line 8, three objects are eligible for garbage collection
B. After line 8, two objects are eligible for garbage collection
C. After line 8, one object is eligible for garbage collection
D. After line 8, none of the objects are eligible for garbage collection
I believe the correct answer is B (two objects eligible for garbage collection).
The reason is that each Student object contains a String object that will also be eligible for garbage collection when a Student object becomes eligible for garbage collection.