Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Boone's Exam #65  RSS feed

bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was taken from Boone's mock exam at:
Question #65
Question 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.
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.
He gives the answer as b,c,e
B is wrong though because while you can request the GC to run, you can not enforce it to run whenever you want to.
C I am not sure about, can anyone help me with that one.
E I know is true.
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill,
Think you're right about b; if it read "You can directly invoke the gc.." then it would be true. Using 'run' is, IMHO, misleading.
As to c, according to Jamie Jaworski in Java 2 Certification one of the gc's activities is:
Informing selected objects that they are no longer in use and that they should release any nonmemory resources.
I think the informing bit has to do with the gc calling <code>finalize()</code> before destroying the object; since the Java Programming Language by Gosling and Arnold says the <code>finalize</code> method should be used to clean-up any non-memory items.
Hope that helps.
The cure for boredom is curiosity.
There is no cure for curiosity.
-- Dorothy Parker
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!