Garbage Collections

Q1: Which statement is true?

A Calling Runtime.gc() will cause eligible objects to be garbage collected.

B The garbage collector uses a mark and sweep algorithm.

C If an object can be accessed from a live thread, it can't be garbage collected.

D If object 1 refers to object 2, then object 2 can't be garbage collected.

ANS:C - If an object can be accessed from a live thread, it can't be garbage collected.

This is a great way to think about when objects can be garbage collected. Option A and B assume guarantees that the garbage collector never makes. Option D is wrong because of the now famous islands of isolation scenario.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.