• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

GC related to certification

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
maha anna:
i have gone through many of the previous forums regarding GC,
Actually I would like to get an answer to one.
as far as the certification goes.What should be the answer to
the following Q,
when will the obj ref by s be GC.
void meth()
{
1: String s="vijay";
2: s=null;
3: String s="vijay1";
}
I understand that String literals are never candidates for garbage collection,So in this case line 2 is the correct answer or "vijay" will not be collected at all.remains alive till the class obj remains alive.
if the answer is line two,will such questions be involved in certification.
 
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The string object referenced is not eligible for GC. You are correct, the only objects eligible for GC are those created with new Also, my understanding is that String GC questions on the exam always refer to string created using the "new" keyword. So did the one GC question I got on the exam.
Bosun
 
Ranch Hand
Posts: 3143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since this is related specifically to Certification I'll move it over to the Programmer Certification Study forum.
reply
    Bookmark Topic Watch Topic
  • New Topic