188k views
5 votes
The java run time system automatically calls this method while garbage collection.

(a) finalizer()
(b) finalize()
(c) finally()
(d) finalized()
(e) none of the above.

User Birb
by
7.8k points

1 Answer

4 votes

Final answer:

The finalize() method is automatically called by the garbage collector before an object is reclaimed by the memory management system.

Step-by-step explanation:

The correct answer is (b) finalize().

The finalize() method is a special method in Java that is automatically called by the garbage collector before an object is reclaimed by the memory management system. It allows the object to perform any necessary cleanup operations before it is destroyed. The finalize() method is a part of the object's lifecycle and can be overridden by a class to define its own cleanup behavior.

For example:

class MyClass {
protected void finalize() throws Throwable {
// Cleanup code here
}
}

User M Sach
by
7.8k points