• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

from MIND q,s TEST, ON great GC-plz help bill and others

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String name;
String newName = "Nick";
newName = "Jason";
name = "Frieda";
String newestName = name;
name = null;
//Line A
1.how many objects are eligible for GC? after name=null.
2.Strictly speaking string literals are not eligible for GC then
why such a question in almost all mock exams.?
3.Do we get a similar question in SCJP also? if so then what should be our answer PLEASE clarify .
Thanks in advance,
sunil.s
------------------
"Winners don't do different things
They do things differently"
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i used to think that. but now i think they are elegible when there is no reference to them any more.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Strings make lousy example objects for questions about GC because of the "intern()" String pool. If I write any more questions about GC I swear I won't use Strings
Bill
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Only object "Nick" is eligible for gc.
[This message has been edited by Jenny Xia (edited December 22, 2000).]
 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Sunil Kumar,
One new thing i learned from you'r post.
"Strictly speaking string literals are not eligible for GC"

Well can you shed more light on this or may be give reference of book/site from where you got this information. I refer RH and Exam Cram but have not found this thing there...

Regards,
Raj.
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even I have the notion that,JRE don't make string pool to force GC.It keeps the string pool even it go out of scope.Am I correct?
 
reply
    Bookmark Topic Watch Topic
  • New Topic