• Post Reply Bookmark Topic Watch Topic
  • New Topic

Uncaught exception  RSS feed

 
Alexandru Puiu
Greenhorn
Posts: 22
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there!

So I have the following code:



I know that the correct answer is: "12, followed by a stack trace for a NumberFormatException", but on the answers there is also the option: "An uncaught exception is thrown". The book says that is not correct. But why? The "NumberFormatException" is thrown and it is uncaught.  I know that it is an unchecked exception, so technically I don't have to handle it, but then again it is thrown and it is uncaught.
 
Knute Snortum
Sheriff
Posts: 4281
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This looks like a Java certification question.  Please post the entire question and quote the source you got it from.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once you have posted the source, read the question carefully: does it say something like, “what is the output from running this program?” If so, then the 12 is an essential part of the output, and throwing an Exception without the 12 would be incorrect.
 
Alexandru Puiu
Greenhorn
Posts: 22
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was it! Thank you! The question was: "What is the OUTPUT of the following program?". I would have never seen it, so thank you again.

The question is from OCA book by J. Boyarsky and S. Selikoff. Question 11 from the Review Questions / Chapter 6.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alexandru Puiu wrote:. . . Thank you! . . . The question is from . . .
That's a pleasure and thank you for posting the source. Sorry for delay in replying.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!