A

Admin • 802.91K Points
Coach

Q. How many of the String objects are eligible for garbage collection right before the end of the main method?

Code:
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;
}
  • (A) None
  • (B) One
  • (C) Two
  • (D) Three
  • Correct Answer - Option(C)
  • Views: 3
  • Filed under category Java
  • Hashtags:

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.