Tuesday, 6 August 2013

Will the finally block be executed?

Will the finally block be executed?

I have read that finally block is always called after the try catch block.
I have a situation(please don't go syntactically)
SITUATION 1:-
try
{
return 1;
}
catch()
{
return 2;
}
finally()
{
return 3;
}
And another situation as:-
SITUATION 2:-
try
{
System.exit();
}
catch()
{
return 2;
}
finally()
{
return 3;
}
My question is that in both the situations will the finally block be
executed if my code is entering in the try block? If not please explain
the reason.
My understanding is that exit is a system call and return is a function call.

No comments:

Post a Comment