Exception Handling 1742358615
Exception Handling 1742358615
1. What is an Exception?
➔ It is an unexpected break in the program's flow that can cause the program to crash.
4. Can we keep other statements in between try, catch and finally blocks?
➔ No. Between the try, catch, and finally blocks, no further statements should be
written. They work together as a single entity.
5. Can we write try block without catch and finally block?
➔ No, it is not mandatory that each try block must be followed by a catch block in Java.
6. There are Three Statements in try block – Statement1, Statement2, Statement3. After
that there is a catch block to catch the exceptions occurred in the try block. Assume
that exception has occurred in statement2, Does the statement3 get executed or not?
➔ No. If the statement2 is having exception within try block then the statement3 will
not get executed.
7. What is unreachable catch block error? Explain the hierarchy of exceptions in Java?
➔ A block of statements to which the control can never reach under any case can be
called as unreachable blocks.