• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Quession of gc

 
Hades Pan
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jennifer thatw as the coolest of all
lol
------------------
coffee drinker
 
Hades Pan
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank Jennifer~~!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic