The `try` block is used to enclose code that might throw an exception, while the `catch` block is used to handle the exception.