Home / Java Programming / Garbage Collections :: Discussion

Discussion :: Garbage Collections

  1. Which statement is true?

  2. A.
    Programs will not run out of memory.
    B.
    Objects that will never again be used are eligible for garbage collection.
    C.
    Objects that are referred to by other objects will never be garbage collected.
    D.
    Objects that can be reached from a live thread will never be garbage collected.

    View Answer

    Workspace

    Answer : Option D

    Explanation :

    Option D is correct.

    Option C is wrong. See the note above on Islands of Isolation (An object is eligible for garbage collection when no live thread can access it - even though there might be references to it).

    Option B is wrong. "Never again be used" does not mean that there are no more references to the object.

    Option A is wrong. Even though Java applications can run out of memory there another answer supplied that is more right.


Be The First To Comment