File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Quession of 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 "Quession of gc" Watch "Quession of gc" New topic

Quession of gc

Hades Pan
Ranch Hand

Joined: Nov 25, 2001
Posts: 106
1.public static void main(String args[]) {
2. Object o=new Float(12.4f);
3. Object []oa=new Object[1];
4. oa[0]=o;
5. o=null;
6. oa[0]=null;
7. return 0;
Where will be the garbage collecter may invoke?
a) just after line no.5
b) just after line no.6
c) just after line no.7
d) never invokes
e) compilation error
Jennifer Warren
Ranch Hand

Joined: Aug 24, 2001
Posts: 53
Answer is e). Compilation error.
As the main methods return type is void and here in the code on line 7 return 0; will give u an error.
Further, one can never be sure that when Garbage collector will be invoked as it is a low priority thread.

amit mawkin
Ranch Hand

Joined: Oct 31, 2001
Posts: 73
Jennifer thatw as the coolest of all
coffee drinker

regards, Amit
coffee drinker and Sun Certified Programmer for Java 2 Platform
Hades Pan
Ranch Hand

Joined: Nov 25, 2001
Posts: 106
Thank Jennifer~~!
I agree. Here's the link:
subject: Quession of gc
It's not a secret anymore!