Question: How many Gems objects are eligible for garbage collection right before the end of the main() method? A. None B. One C. Two D. Three
How many Gems objects are eligible for garbage collection right before the end of the main() method?

A. None
B. One
C. Two
D. Three
E. Four
F. The code does not compile
public class Gems { public String name; } public Gems (String name) { this.name= name; } public static void main(String... args) { var g1 = Gems ("Garnet"); var g2 = Gems ("Amethyst"); var g3 = Gems ("Pearl"); var g4 = Gems ("Steven"); g2 g3; g3 = g2; } g1 = g4 = g2; null;
Step by Step Solution
3.49 Rating (149 Votes )
There are 3 Steps involved in it
To determine how many Gems objects are eligible for garbage collection right before the end of the m... View full answer
Get step-by-step solutions from verified subject matter experts
