Question
Question 3: What is the difference between `try-catch` and `catch-finally` blocks?
Asked by: USER4546
82 Viewed
82 Answers
Answer (82)
The `try-catch` block is used to handle exceptions that might occur during the execution of a code block. The `catch-finally` block is used to execute code regardless of whether an exception is thrown or not. `try-catch` is for handling errors, while `finally` is for cleanup tasks (like closing files).