This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

again on GC

 
sheri
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
raghurajput
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • 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).]
 
Stephanie Grasson
Ranch Hand
Posts: 347
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sheri,
Look at this page:
http://www.javaranch.com/ubb/Forum24/HTML/003438.html
Hope it helps.
Stephanie
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic