InterviewSolution
| 1. |
What Is Multi-catch Statement In Java 7? |
|
Answer» Before Java 7 multi-catch statement, if two or more exceptions were handled in the same way, we still had to write separate catch blocks for handling them. catch(IOEXCEPTION exp){ With Java 7 and later it is possible to catch multiple exceptions in one catch block, which ELIMINATES the duplicated code. Each EXCEPTION TYPE within the multi-catch statement is separated by PIPE symbol (|). catch(IOException | SQLException exp){ Before Java 7 multi-catch statement, if two or more exceptions were handled in the same way, we still had to write separate catch blocks for handling them. catch(IOException exp){ With Java 7 and later it is possible to catch multiple exceptions in one catch block, which eliminates the duplicated code. Each exception type within the multi-catch statement is separated by Pipe symbol (|). catch(IOException | SQLException exp){ |
|