 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can handle multiple exceptions in Java. Before starting, you can subscribe my YouTube channel by clicking on the link which is available at bottom right corner of this video. You can download my app Techimage that is available on Google Play. You can connect with me by following these details which are available in front of you. Now, coming on to the topic. In this example, I am going to demonstrate you how you can handle two exceptions using try and catch in Java. So, name of classes test which is containing main method. Inside main method, I have initialized an array with five values, one, two, three, four, five. Then I have declared some variables I and D and R and D are initialized with 150 respectively. Then I have implemented a try block. This is try block which is containing a message array contains so it will be displayed first. Then I have implemented a loop which is starting from zero and it is ending till I less than five. It will display elements of array on control. Then R equals to N by D. So here I am dividing N by D and the result will be stored inside R. That R value of R is displayed with the help of this system.out.print talent. So here in this try, I am performing two operations. First is printing of array and second is division of two elements and printing of the result. Just after the try block, I have implemented two catch blocks. First one is for arithmetic exception and second one is for array index out of bound exception. After implementation of these catch blocks, I have written system.out.print talent which will display end of program message on screen. It is not part of try and catch. So if any exception is available, then also this end of program will be displayed and if no exception is available, then also it will display. So now I am executing this code first. You can see that array contains one, two, three, four, five is printed properly and division result two is displayed here. It means right now no exception is generating and proper results are displayed here and at last end of program is displayed. Now first I am generating exception for array. So this condition is now i less than 15. So actual size of array is five. It means we can repeat loop five times but I am repeating it 15 times. Let's see what happens now. I am executing this code. You can see that array contains one, two, three, four, five is printed when it is trying to access sixth index that is not available because it is out of bound of that array. So array index out of bound message is printed and then end of program is displayed. So friends, exception is occurred in this loop. So after this loop, line number 14 and 15 are available which has not executed this time because exception has generated and control is transferred on this catch lock. Array index out of bounds exception. That's why array index out of bound is displayed and after completion of this catch lock remaining codes has been executed properly. Now, if I remove 15 and I write five here, it means no exception will be generated through this loop. This time I am assigning zero into D. I am executing this code. Let's see what happened. Array contains one, two, three, four, five is printed properly. This time division by zero exception is raised and catch block is worked as per this requirement and again end of program is displayed. So this time second exception has worked, which is arithmetic exception division by zero. So friends, I hope you have understood the working of multiple catch blocks for a single try block in this single try block. There are two exceptions. One is arithmetic exception division by zero and another one is array index out of bounds exception. So if you want to implement multiple catch blocks for a single try block, then it is possible because any try block can contain more than one errors. If you want to handle those errors, you can implement multiple catch blocks and the benefit of implementing try and catch is that if any error is available in the code, then that piece of code will be terminated and remaining code will be executed properly. So in this example, end of program, a message has been printed whether exception is available or not. If you type more instructions after this statement system.out.println end of program, then those statements will also be executed properly, whether exception is available or not. So do implement this example so that you can understand the concept of multiple exception handling using multiple catch blocks in Java. If you want to watch more programming related videos, you can subscribe my YouTube channel. Thank you for watching this video.