try
{
some code
}
catch()
{
some code
}
finally
{
some code
}
try
{
some code
}
catch()
{
some code
}
finally
{
some code
}
I know that if an exception is thrown in the first try block, then the first finally block will be executed. What about the second finally block?
Also, if you want to display the message to user when an exception arises, then where you should write that message, and how you should display it?
FYI, I was recently asked these questions in an interview, and was stumped.
Copy and paste this code into an editor. Then play around with it, uncommenting and re-commenting various lines. Then compile and run the code. Keep doing this until you’re pretty comfortable that you know everything about it. This is what I recommend you do when you find all such confusing questions, that are simply based on flow control. That is how you will learn programming flow control.