• 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

Checked vs Unchecked Excpetions - doubt

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends,
I am preparing to go for the SCJP1.4,and while studying exceptions i have this small doubt.Checked Exception always need to be handled or declared,while unchecked do not.So,how would I know which exceptions are checked and which are not.Do i need to memorize all the exceptions under RuntimeException to know these are the unchecked one's and rest all checked.Thanks in Advance.
 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should probably memorize the most common ones. Here are a few I can think of:

Unchecked exceptions include:
NumberFormatException
ArithmeticException (integer divide by zero)
NullPointerException
IllegalThreadStateException
IllegalArgumentException
ClassCastException
ArrayIndexOutOfBoundsException

Checked exceptions include:
InterruptedException
java.io.IOException
 
Ranch Hand
Posts: 214
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Memorization is the best strategy for the exam. But you don't need to memorize every single descendant of RuntimeException. I think the K&B book suggests a list you should know.

I don't have the book handy at the moment but my list would include
  • ArithmeticException
  • IndexOutOfBoundsException[LIST]
  • ArrayIndexOutOfBoundsException
  • StringIndexOutOfBoundsException
  • IllegalThreadStateException
  • IllegalArgumentException
  • NumberFormatException
  • NullPointerException
  • [/LIST]

    You probably also want to memorize that InterruptedException is a checked exception.

    You should anticipate having a couple of questions on the exam that indirectly require that you know that Exceptions that are not RuntimeExceptions have to be declared or handled.

    By indirect I mean that the question won't be asking about exceptions explicitly but instead, maybe something to do with inheritance.
     
    Jas Oberai
    Ranch Hand
    Posts: 231
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Ok Thanks Guys..I was also probably thinkin that i need to memorize them......thanks.
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic