How many of the String objects are eligible for garbage collection right before the end of the main method?
public static void main(String[] fruits) { String fruit1 = new String("apple"); String fruit2 = new String("orange"); String fruit3 = new String("pear"); ? fruit3 = fruit1; fruit2 = fruit3; fruit1 = fruit2; }
C.
All three references point to the String apple.
This makes the other two String objects eligible for garbage collection and Option C correct.