When is the finalize() method called?

Java MCQ: When is the finalize() method called?

a) Before garbage collection
b) After garbage collection
c) Before object creation
d) After object creation

Answer:

a) Before garbage collection

Explanation:

The finalize() method is called by the garbage collector on an object when it determines that there are no more references to the object. It allows the object to clean up resources before being garbage collected.

Reference links:

https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top