If it is caught in the inner try block then will the outer finally block be called?
And if you throw an exception from the first catch block where does it go. Is it like an exception occuring in the outer most try block so it goes to the outer most try block or is it go to the next catch block in the inner try that is of that type assuming you have one?
If you have nest finally blocks then if the inner most finally is called does the outer ones get called as well or do you have to rethrow it?
If the outer most try block gets called then then does the inner finally blocks get called?
If you catch an exception in the inner try block and throw an exception does the new exception get caught in one of the parent try blocks?
What happens if you throw a new exception that is a superclass of any exceptions that the parent catch blocks can catch?
The best way to learn is to experiment. Try putting some code that throws exceptions inside your try block and see what happens. Try different exceptions/multiple catch blocks/no catch block (just a try and finally).
If you get any results you weren't expecting or don't understand, then come back and ask about them specifically.
Joined: Feb 06, 2008
Ok, I figured out most of the questions but I still don't know about the finally block.
Does it get called automatically after you leave the try block. Or After you leave the entire function.
And will the finally block be always called no matter where it is or how many nested try blocks you have?