nagaraj raja
,
Ranch Hand
Aug 19, 2005 15:33:00
hai , Here i am thinking answer is c is it right plz explain?
Mark Spritzler
,
ranger
staff
Aug 19, 2005 17:32:00
How about A? Mark
Mark Spritzler
,
ranger
staff
Aug 19, 2005 17:33:00
But you know what, I think combining String Objects and a question about Garbage Collection together is just mean. It ends up asking about two seperate things. 1. Garbage Collection 2. Which Strings are in the String Pool and which are Objects on the heap. Mark
Rubens Gomes
,
Greenhorn
Aug 19, 2005 18:49:00
b) 1 --> "Nick" is the only object which does not have a stack variable reference pointing to it. The other Strings have references to them.
Shivani Chandna
,
Ranch Hand
Aug 20, 2005 04:56:00
String name; String newName = "Nick"; newName = "Jason"; name = "Frieda"; String newestName = name; name = null; //Line A
I think it should be 2 .... name and "Nick" string object lost am i wrong?
Arvind Giri
,
Ranch Hand
Aug 20, 2005 05:44:00
I think < (b) 1 > is correct. As there were only 3 objects and 2 are being referenced. So its "NICK" which is eligible for garbage collection. further u can't take name as object its only reference variable.
Shivani Chandna
,
Ranch Hand
Aug 20, 2005 05:55:00
Originally posted by Arvind Giri: [QBfurther u can't take name as object its only reference variable.[/QB]
Right if newestName didnt refer to the object refer by name then doing name=null wd make 2 objects elegible for GC. Thanks !
Steve Sugden
,
Greenhorn
Aug 20, 2005 06:08:00
For what its worth, I agree with Rubens and Arvind. "Nick" appears to be the only String object not referenced. Are we right? Can I have my certificate now?
See where your hand is? Not there. It's next to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com