Archana - there is a way to make a string object...like this:
String str = "abc";
this creates one reference variable (str) which points to a String literal ("abc") which is thrown into the "String pool". The String pool is not garbage collected. It is in non-normal memory. Normal memory is garbage-collectable.
Now here's a funny thing. There is another way to create a String object... except that this way creates TWO string objects!
String str = new String("abc");
Here, there is still ONE reference variable (str), but TWO objects. One is created in the "String pool" in non-normal memory, and ONE IS CREATED IN NORMAL MEMORY. So this way, there IS a String object that is created that will potentialy be available for garbage collection if later on no references point to it.
As the first technique for creating a String is used in the original question code, there is no String object that may be eligible for garbage collection....
So only Object A = new Object is creating an object which becomes available for garbage collection.
[ March 01, 2003: Message edited by: Jasper Vader ]