Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mock q on garbage collection

 
sandu sudhakar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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?
 
Sudhakar Namasivayam
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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..
 
Manikandan Jayaraman
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
I got it..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic