This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes again on GC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "again on GC" Watch "again on GC" New topic
Author

again on GC

sheri
Ranch Hand

Joined: Sep 14, 2000
Posts: 43
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

Joined: Sep 03, 2000
Posts: 7
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

Joined: Jun 14, 2000
Posts: 347
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
 
subject: again on GC
 
Similar Threads
GC Stuff
garbage collection question
Garbage collection questions in MindQ exam
Garbage Collection????
garbage collection