Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

mock q on garbage collection

 
Greenhorn
Posts: 4
  • 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 about garbage collection are true?

A) The garbage collector runs in low memory situations
B) You can run the garbage collector when ever you want.
C) When it runs, it releases the memory allocated by an object, which is no more in use.
D) Garbage collector immediately runs when you set the references to null.

I expect the answer to be C.
But given answer is A,C.
Not convinced about A. Garbage collector frees memory. But does it have something to do with low memory situation?
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The main purpose of having a garbage collector is to free up space so that more memory is available for applications.. So the option is kinda obvious..
 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, As always said, please mention the link of this mock test or atleast the name of the mock test. Else it is very hard for us to check on that.

Even I find choice A to be a less appropriate one. As mentioned in K&B book, one thing is for sure. The Garbage Collector will run once, DEFINITELY before your JVM crashes due to low memory.

I dont accept choice A for sure anyways. Hope you dont get such ambiguous questions in your exam
 
sandu sudhakar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Thanks for the response.

---------------------------------------------------------------------------
The main purpose of having a garbage collector is to free up space so that more memory is available for applications.. So the option is kinda obvious..
--------------------------------------------------------------------------

But garbage collector runs in high memory situations too..that's why I'm against choice A.

----------------------------------------------------------------------------please mention the link of this mock test or atleast the name of the mock test. Else it is very hard for us to check on that.
---------------------------------------------------------------------------
http://www.javacaps.com/scjp_mockexams1.html
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It didn't say the Garbage Collector runs only in low memory situations.
 
sandu sudhakar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it..
 
Remember to always leap before you look. But always take the time to smell the tiny ads:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic