What is the correct statement about the __del__() method in Python?

Options

  • A. It is called when an object is initialized
  • B. It is a finalizer that may be called when an object is about to be destroyed
  • C. It is used to create a new object
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. It is a finalizer that may be called when an object is about to be destroyed

Detailed Explanation

The __del__() method is a finalizer. Its execution timing is not guaranteed, so it should not be relied upon for deterministic resource cleanup.