This question is from Javacaps mock 1 Q12 Here the answer given is A but since according to our final discussion string literals are not garbage collected then the answer should be D. Am i right?
String string1 = "Test"; String string2 = "Today"; string1 = null; string1 = string2; A) 1 B) 2 C) 3 D) 0 another question no 11 A) The garbage collector runs in low memory situations B) You can run the garbage collector when ever you want. C) When it runs, it releases the memory allocated by an object, which is no more in use. D) Garbage collector immediately runs when you set the references to null. Ans given is A and C but i feel it should be only C Please someone help Neha