• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Programmatically thrown exceptions

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 - java.io.IOException
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'?
 
Marshal
Posts: 79240
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic