posted 19 years ago
Hi,
When foo(0) is executed, the output value is "134", since catch block is not executed.
When main method calls the foo(1) method, the output value continues with the "134" value, since output is static string variable.Only one copy of output is created.
When foo(1) is executed, the output value is "1342", since in the catch block, there is a return statement. 3 and 4 values cannot be appended to the output variable. Here, return statement stops the execution of finally and outside the finally block code and returns to the main method.
So, the value of output variable is "134" before calling foo(1) and "1342" after calling foo(1).
As per my knowledge, the above analysis is correct.
If there is any mistake, sorry for the reply.