This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Programmatically thrown exceptions

Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused by questions such as  "Which of the following exceptions are always thrown programmatically?"
So I thought this was a distinction between checked and unchecked exceptions, but it seems this isn't the case.

This was one of the qs on the practice exam from Sybex with the following options:
A - ArrayIndexOutOfBounds
B - ExceptionInInitializerError
C -
D - NullPointerException
E - NumberFormatException

The answer says "All of these exceptions can be thrown programmatically, but the question asks which ones always are. An
IOException is thrown by many methods that read/write files and is always thrown programmatically. Similarly, NumberFormatException is thrown when convering numbers. The other three are thrown by the JVM"

I just can't get my head around what exactly it means by 'programmatically thrown'?
Posts: 69799
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You appear not to have found the correct place for your post; never mind because I shall move you. I hope to the right place

Thank you for telling us where that question comes from; is that Boyarsky and Sellikoff?

What thrown programmatically means is that the exception is the result of a statement like throw new XYZException("Something bad."); That means that methods which read numbers have throw new NumberFormatException("1234567891011121314151617"); in, or similar, and methods to read files have such throw statements for IOException. If you suffer a NullPointerException on the other hand, there may not be a throw statement anywhere.
Lookout! Runaway whale! Hide behind this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic