Which of the following statements are true about the finalize() method?

Java MCQ: Which of the following statements are true about the finalize() method?

a) It is called before an object is garbage collected
b) It can be overridden in a subclass
c) It is used to clean up resources before object destruction
d) All of the above

Answer:

d) All of the above

Explanation:

All the statements are true. The finalize() method is called before an object is garbage collected, can be overridden in a subclass, and is used to clean up resources such as closing files or releasing memory before the object is destroyed.

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