Frequent Questions      

  Java Certification: SCJP 6- Sun Certified Java Programmer Exam 


Garbage Collection


           Up           Previous                 Next

Q2. How can you force garbage collection of an object?

A. Garbage collection cannot be forced.
B. Call System.gc().
C. Call System.gc() passing in a reference to the object to be garbage collected.
D. Call Runtime.gc().
E. Set all references to the object to new values(null, for example).

  Correct Answer: A



A is correct. Garbage collection cannot be forced.
B and D are not correct as calling System.gc() or Runtime.gc() is not 100 percent
reliable, since the garbage collection thread might defer to a thread of higher 
C is incorrect as gc method does not take argument.
E makes object to be garbage collected while next time it refers.

   Up           Previous                 Next

Disclaimer: All Simulation Exams practice tests, study guides and/or material are neither sponsored by, nor endorsed by, nor affiliated with Cisco® Systems, Inc., Microsoft® Corporation, Inc., CompTIA® , Check Point Software Corp., Prosoft® or any other company. All trademarks are trademarks of their respective owners and duly  acknowledged. MCSE ™, MCSE+I ™ are registered trademarks of Microsoft® Corporation and CCNA™, CCNP™, CCIE™ are registered trade marks of Cisco® Systems. A+™, Network+™, i-Net+™, Server+™ are registered trade marks of CompTIA®. CCSA™, CCSE™ are registered trademarks of CheckPoint® Software Corp. CIW™ is a trade mark of Prosoft®. Thank-you for your interest in Simulation Exams. Please see read me file before you download, install, and/or use any software from SimulationExams.com  For any information or questions regarding this Website, please e-mail webmaster at simulationexams.com

Copyright © 2000-2015 SimulationExams.com All rights reserved

Website design by Anandsoft.com