Question OOP-CTOR-0056
MediumWhy is Java's finalize() not a good replacement for a C++ destructor?
- A.
It cannot access fields
- B.
It runs twice
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Constructors and Destructors question
Why is Java's finalize() not a good replacement for a C++ destructor?
It cannot access fields
It runs twice
Sign up free to see the answer and a step-by-step explanation.
The garbage collector may run it late or never, so cleanup timing is unpredictable
It runs before the constructor