Hello !
Consider this code;
void f(int x) { try { g(x); Out.print('e'); }catch (E1 e) { Out.print('f'); } Out.print('g'); } void g(int x) throws E1 { try { if(x <= 0) throw new E1(); else if( x > 10) throw new E2 (); Out.print('a'); } catch (E2 e) { Out.print('b'); }finally { Out.print('c'); } Out.print('g'); }
What I want to figure out (without running the code!) is what would be the output of the program when we call the function f in 3 diffrent ways;
f(0) f(3) (f12)
Now for f(3) I think the output should be this;
f(0) = c g e f g
f(3) = a c g e g
f(12) = b c g e g
Now I really really want to do this without having to write the Exception classes and just running the code,that would be cheating and I do not want to cheat.Would you say this is the output for when we pick f to be 0 3 and 12? The part that is troubeling me is the if and else if part.I am not sure when the part after the if else will be executed (the printing of a).
Looking forward to your answers.
Thank you!