This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GC
 
Similar Threads
implementing multiple inheritance in java
Late Binding
Overloading & Overriding!
Need Help
jtips 1, q26