• 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

 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the following statements related to Garbage Collection are correct. Select all correct answers.
A. It is possible for a program to free memory at a given time.
B. Garbage Collection feature of Java ensures that the program never runs out of memory.
C.It is possible for a program to make an object available for Garbage Collection.
D. The finalize method of an object is invoked before garbage collection is performed on the object.
Correct Answers: C and D
Could anyone explain why B is not included in the answers?
 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Garbage collection does not ensure a program never runs out of memory. It's still possible gc may never run during a program execution, if badly written - the program will definitely run out of memory.

------------------
Velmurugan Periasamy
Sun Certified Java Programmer
----------------------
Study notes for Sun Java Certification
http://www.geocities.com/velmurugan_p/
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
B. Garbage Collection feature of Java ENSURES(?) that the program never runs out of memory.
"Java performs GC for you and eliminates the need to free objects explicitly." pg. 47
"GC is not a Guarnatee that memory will always be available
for new objects. You could create objects indefinitely, place them in lists and continue ...
GC solves many, but not all memory allocation problems." pg. 48

Java ProgLang(2nd Edition) Arnold,Gosling
 
Charlie Swanson
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I was thinking that garbage collection cleans up the objects that do not have a reference and thus makes sure that
the system has enough memory especially when the system is low on resources.
 
reply
    Bookmark Topic Watch Topic
  • New Topic