File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes GC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "GC" Watch "GC" New topic
Author

GC

josephine chen
Ranch Hand

Joined: Oct 29, 2002
Posts: 216
public class Tester extends Applet {
int a = 3;
String b = "fred";
String c = b;
Object d = new Object();
public void init() {
methodA(b);
methodB(d);
a = 5;
}
void methodA(String b) {
b = c;
c = null;
}
void methodB( Object o) {
d = new Object();
}
}
How many objects are available for GC when init() has completed?
a.0
b.1
c.2
d.3
e.4
gunjan
Ranch Hand

Joined: Jan 28, 2000
Posts: 33
Answer 1.
After
void methodB( Object o) {
d = new Object();
}
is executed, the object created by
Object d = new Object();
has no reference to it and hence is available for GC


Regards<BR>Gunjan
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: GC