Bird
0
0

Which of the following best describes the role of the finalize() method in Java's object lifecycle?

easy📝 Conceptual Q2 of 15
Java - Classes and Objects
Which of the following best describes the role of the finalize() method in Java's object lifecycle?
AIt prevents the object from being garbage collected
BIt is used to create a new object
CIt is called by the garbage collector before reclaiming the object
DIt initializes the object after creation
Step-by-Step Solution
Solution:
  1. Step 1: Understand finalize() method purpose

    The finalize() method is called by the garbage collector before reclaiming memory.
  2. Step 2: Clarify other options

    It does not create or initialize objects, nor prevent garbage collection.
  3. Final Answer:

    It is called by the garbage collector before reclaiming the object -> Option C
  4. Quick Check:

    finalize() called before GC = D [OK]
Quick Trick: finalize() runs before object removal by GC [OK]
Common Mistakes:
  • Thinking finalize() creates or initializes objects
  • Believing it stops garbage collection
  • Confusing it with constructors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes