• 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

again on GC

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How many objects are eligible for garbage collection once execution has reached the line labeled Line
A?
String name;
String newName = "Nick";
newName = "Jason";
name = "Frieda";
String newestName = name;
name = null;
//Line A
a) 0
b) 1
c) 2
d) 3
e) 4
please explain
thanks
sherin
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How many objects are eligible for garbage collection once execution has reached the line labeled Line
A?
String name;
String newName = "Nick"; //newName points to "Nick"
newName = "Jason"; //now newname points to Jason, so Nick is eligible for garbage collection, our count=1;
name = "Frieda"; //name points to "Frieda"
String newestName = name; //newestname refers to name, hence "object" "Freida" is refered to by two variables.
name = null; // here you set name=null, but still newestname points to "Freida", so our count is still 1
//Line A
a) 0
b) 1 //ANS
c) 2
d) 3
e) 4

[This message has been edited by raghurajput (edited September 14, 2000).]
 
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sheri,
Look at this page:
http://www.javaranch.com/ubb/Forum24/HTML/003438.html
Hope it helps.
Stephanie
 
We're being followed by intergalactic spies! Quick! Take this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic