In Java, there is an inbuilt function to handle exceptions. The normal code for which exception has to be handled first goes in the “try” block and the code for handling the exception goes into the “catch” block.

Below is the syntax for the try and catch block:

try{
   statement(s)
}
catch (exceptiontype name){
   statement(s)
}

Note: This is one of the software engineering interview questions for experienced candidates.

BY Best Interview Question ON 01 Feb 2020