That's a very tricky question.Here goes...
1)When method call(int) is invoked,local variable x is assigned the value 5.Initially x=5.
2)The expression
is evaluated.Statement consists of unary as well as binary operators.The current value of x will be substitued.So now the expression looks like
5--x/0;
Now x will be decremented,since we have a post fix operator.Thus now the values are
x->4;
expr.-> 5--4/0.
4/0 will throw an ArithmeticException and control passes to catch block
3)Catch block contains expression
Now x will be decremented,since we are using a prefix operator.Thus values will be
x->3
expr.->3-3%0.
3%0 will throw an Arithmetic Exception and execution proceeds to finally block.
4)In the finally block,
Current value of x will be returned,which is 3.
Now x will be decremented,since a post fix operator is used.However,that value is lost as local variables go out of scope once method exits.
I just changed the code to
I hope that helps.
------------------
Udayan Naik
Sun Certified
Java 2 Programmer
[This message has been edited by Udayan Naik (edited March 06, 2001).]