Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question to test you

 
Venkat Raman
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was just trying questions when this one occurred to me.
Pl tell the output of the program


[This message has been edited by maha anna (edited April 01, 2000).]
 
Venkat Raman
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry it's posted twice.
This is the real one
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't you think the code should be modified in order to print any value of i?

The spelling of "AritmeticException" should be "Arithmetic Exception".
The return statement should appear after finally clause in order to compile the program.
In this case the output of the program shall be
"exception /by zero", "Its all over..i'm quitting" and 6. The program continues the execution of the main method after the execution of the try/catch/finally statement.
I hope your question was intended to produce the above output. The program wont compile in its original version.

[This message has been edited by maha anna (edited April 01, 2000).]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can also put "return z" inside the finally block instead of outside the finally block. In case of methods that return a value all the paths of execution should either return a value or throw an exception in order for it to compile. This program shall also compile if the method throws a new exception in the end.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic