When do you use a catch block and when do you use a finally block?

We use a catch block when we want to handle the exception scenario. We use a finally block alone when we want to do some cleanup but at the same time propagate the exception to the caller. We use a finally block together with a catch block when we want to do something irrespective of what exception is thrown.


Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email