πŸ“Š JAVA
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
πŸ’¬ Discuss
βœ… Correct Answer: (C) Two

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
406
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Ram Sharma
Publisher
πŸ“ˆ
80%
Success Rate