Multiple choice

Which statement is true?

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

  2. The garbage collector uses a mark and sweep algorithm.

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

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

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

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.