IF you have catch blocks for specific types and that type of exception occurs, it will execute. Example catch(NullReferenceException e)() so if null reference exception occurs it will go here. ---------------------------------------------------------------------------------------------- Also ordering is very important in multiple catch blocks.Put specific catch blocks first then generic.For example catch(Exception e) will catch all type of exceptions, so put it last.
In this case, the order of the catch clauses is important because the catch clauses are examined in order. Catch the more specific exceptions before the less specific ones. The compiler produces an error if you order your catch blocks so that a later block can never be reached.
Depend on the exception raised.
Compiler will look for a related catch block, if it is not found, then it will throw an unhanded exception. For instance, if arithmetic exception occurs in the try block, then it will look for the Arithmetic catch (ArithmeticException e) block or the general exception block, if both are not found, it will throw an unhandled exception for sure.
The first one which matches the type of exception thrown. Normally we go from most specific to most generic. The last one is usally simply an “Exception” type and hence if the exception is not caught by any of the specific types it gets caught with the final generic type.
once the exception occur the appropiriate catch will execute if it is not there means the base catch block will execute
know more about this question refer
https://youtu.be/sdjR0D5nyqQ
top to bottom order
If there is a catch block of the exception raised in try block, then respective catch block is executed otherwise the general exception that holds all the exceptions will be executed.