By: Ash Emailed: 1729 times Printed: 2329 times
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).
Answer:A is correct. Garbage collection cannot be forced. Calling System.gc() or Runtime.gc() is not 100 percent reliable, since the garbage-collection thread might defer to a thread of higher priority; thus B and D are incorrect. C is incorrect because the two gc() methods do not take arguments; in fact, if you still have a reference to pass into the method, the object is not yer eligible to be collected. E will make the object eligible for collection the next time the garbage collector runs.
View Tutorial By: Biniam E at 2011-12-17 15:09:09
View Tutorial By: asin at 2013-06-27 15:47:35
Most Viewed Articles (in Certification )
Most Emailed Articles (in Certification)