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? 

public class Gems { public String name; } public Gems (String name)

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

1 Expert Approved Answer
Step: 1 Unlock

To determine how many Gems objects are eligible for garbage collection right before the end of the m... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Oracle Questions!