• 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

Garbage Collection Question

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got this question from Bary Boon's mock exam.

Q 65. Which statements about Garbage Collection are true?

Select all valid answers:
a. You can directly free the memory allocated by an object.
b. You can directly run the garbage collector whenever you want to and it will be schedule in due time..
c. The garbage collector informs your object when it is about to be garbage collected.
d. The garbage collector reclaims an object�s memory as soon as it becomes a candidate for garbage collection.
e. The garbage collector runs in low-memory situations.

The answer given is b,c,e.

The exam was created before JVM 1.4. So I'm pretty sure that b is not correct. I think e is correct. How about c?

Thanks,
Fes
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
C is correct. GC will inform the objects when it goes to collect the objects, by calling finalize method on them.
 
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Java specifications make the following promise about finalize() method:

Before reclaiming the memory occupied by an object that has a finalize() method, the garbage collector will invoke that object's finalize() method.
 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

-->The System.gc() method can be used to request garbage collection,
-->Although Java provides facilities to invoke the garbage collection, explicitly, there are no guarantees that it will be run. The program can only request that garbage collection be performed, but there is no way that garbage collection can be forced.

Above two statements says option 'b' is wrong know.
friends, pls correct me if i am wrong.

Thanx & Regards
Naresh
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic