my dog learned polymorphism*
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


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 "Quession of gc" Watch "Quession of gc" New topic
Author

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;
8.}
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.

Jennifer.
amit mawkin
Ranch Hand

Joined: Oct 31, 2001
Posts: 73
Jennifer thatw as the coolest of all
lol
------------------
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~~!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Quession of gc