Question: What is the difference between finally and finalize blocks?
- The finally block is called during the execution of a try and catch block, while the finalize method is called after garbage collection.
- The finally block is called after the execution of a try and catch block, while the finalize method is called just before garbage collection.
- The finalize block is called before the execution of a try and catch block, while the finally method is called just before garbage collection.
- The finalize block is called during the execution of a try and catch block, while the finally method is called after garbage collection.
Answer: The correct answer of the above question is Option B:The finally block is called after the execution of a try and catch block, while the finalize method is called just before garbage collection.