hi Sandeep ,,
According 2 me...The Ans. will be 0 ...no Objects r eligible for
GC.
But..in the 2nd case I think if u write:
String string1 = new String ("Test");
String string2 = new String ("Today");
The Ans. should be 1 this time.
What I am trying 2 say tha u r right.
the ans. will be 0 and 1 resp.
I think it will help u.
Ratul Banerjee
Originally posted by Sandeep Chaturvedi:
Just to be sure:
Answer to my original question:
From the following code how many objects are garbage collected?
String string1 = "Test";
String string2 = "Today";
string1 = null;
string1 = string2;
A) 1
B) 2
C) 3
D) 0
is 0?
If I replace first 2 lines of codes with:
String string1 = new("Test");
String string2 = new("Today");
Answer would be 1?
Please correct me if I am wrong.