Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

What is finally and finalize in java?

Category: API Testing using Postman

finally block is used with try-catch to put the code that you want to get executed always, even if any exception is thrown by the try-catch block. finally block is mostly used to release resources created in the try block.
finalize() is a special method in Object class that we can override in our classes. This method get’s called by garbage collector when the object is getting garbage collected. This method is usually overridden to release system resources when object is garbage collected.

Leave a Reply

Your email address will not be published. Required fields are marked *