• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

GC Clarification

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Joyce is correct. I have just compiled and run the program to get:

 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, you write to the author of the mock exam and tell them they're wrong.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic