Using a slightly customized edition of Schulz's code:
Code:
try {
try {
A()
} catch (Exception1 obje) {
B()
}
} catch (Exception2 objee){
C()
}
Let us consider that Exception1 and Exception2 do not derive inherit from each other.
If A() throws Exception1, B() will run successfully .
If A() throws Exception2, C() will get executed, and B() will not run
If A() throws Exception3 (which is not caught in this case ), it 'll go up the call
stack.
If A() throws no exception, neither B() nor C() is going to run.
If B() throws Exception1, it will will go up the invoke stack.
If B() throws Exception2, C() will run.
If C() throws some exception, it'll go up the invoke stack.
The multiple try catch statement can also be displayed in the form of nested try statements , the above code displays the same , if the outer block satisfies then it enters the inner block.
Bookmarks