This week's giveaway is in the Testing forum. We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line! See this thread for details.
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.
hi bajaj... if there occurs a return stmt in catch or finally block... the code in finally gets executed and the code after finally gets skipped.... I hope it will make sense....
just try this program without using return statement in catch block then after finally block statement execute easily Do not use number simply use write statement for understanding i did ur program and somewhere my concept is clear if u like my answer then well and good otherwise sorry because i am new player in this field
It's exactly the same and completely different as this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth