ola pessoal,
estava estudando o livro da Kathy Sierra, capítulo 7 (Collections e GC)
e quando fui fazer os testes (15 perguntas no final do capitulo) me deparei com a seguinte questão
Which statement is true?
A. All objects that are eligible for garbage collection will be garbage collected by the garbage
collector.
B. Objects with at least one reference will never be garbage collected.
C. Objects from a class with the finalize() method overridden will never be garbage
collected.
D. Objects instantiated within anonymous inner classes are placed in the garbage collectible heap.
E. Once an overridden finalize() method is invoked, there is no way to make that object
ineligible for garbage collection.
Eu responti que a resposta certa era “B”, mas errei… segue a explicação do livro:
Correto: “D” All objects are placed in the garbage collectible heap.
Incorreto: “A” is incorrect because the garbage collector makes no guarantees. “B” is incorrect because islands of isolated objects can exist. “C” is incorrect because finalize() has no such mystical powers. “E” is incorrect because within a finalize() method, an object’s reference can be passed back to a live thread.