Question 3: What is the difference between `try-catch` and `catch-finally` blocks?

Question

Grade: Education Subject: Support
Question 3: What is the difference between `try-catch` and `catch-finally` blocks?
Asked by:
82 Viewed 82 Answers

Answer (82)

Best Answer
(304)
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).