Which of the following helps in garbage collection?

  1. final

  2. finaly

  3. finalize

  4. finalizer


Correct Option: C

AI Explanation

To answer this question, you need to understand the concept of garbage collection and the role of the finalize method in Java.

Option A) final - This option is incorrect because the final keyword is used to declare a constant or to make a variable, method, or class unchangeable.

Option B) finaly - This option is incorrect because there is no such keyword or method named finaly in Java.

Option C) finalize - This option is correct because the finalize method is a special method in Java that is called by the garbage collector before an object is garbage collected. It allows the object to perform any necessary cleanup operations before it is destroyed.

Option D) finalizer - This option is incorrect because there is no such keyword or method named finalizer in Java.

The correct answer is option C) finalize. This option is correct because the finalize method helps in garbage collection by allowing objects to perform cleanup operations before they are destroyed.

Find more quizzes: