Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GC Clarification

 
Vidyavathi saravanan
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Answer options:
Assume that garbage collection runs and all elligible objects are collected and finalized.
A It does not compile due to incorrect signature of the finalize method.
B It compiles but no text is written when it runs due to incorrect signature of the finalize method.
C Before "exiting" is written, 2 messages from finalize will be printed.
D Before "exiting" is written, 3 messages from finalize will be printed

Which one would be the answer?
(code tag fixed and missing }s added )
[ November 09, 2004: Message edited by: Barry Gaunt ]
 
Jay Pawar
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the answer should be option C. There are two objects which are eligible for garbage collection.
They are the ones which are generated when i=0; and i=1; the object created when i=2; has reference t and obj.

Hope that helps you.
[ November 08, 2004: Message edited by: Jay Pawar ]
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vidyavathi,

I think none of the answers are correct. Even with the assumption that the garbage collector is run, the 2 messages could be printed before or after the "exiting".

Joyce
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joyce is correct. I have just compiled and run the program to get:

 
PNS Subramanian
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assume we face a question like the one above, aren't we suppose to go with option (c) since thats the only possibility ?
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you write to the author of the mock exam and tell them they're wrong.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic