• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Notes on checked/unchecked exceptions--need assistance

 
Dave Reinhardt
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to go thru the SCJP book and also the Sun exam objectives and organize some notes on the subject of exceptions. All the exceptions listed in the objectives seem to be unchecked exceptions (they are subclasses of RuntimeException or Error). I see nothing listed on direct subclasses of Exception, so I'm wondering which checked exceptions were are supposed to know for the exam. Can anyone help or refer me to some notes on exceptions?

Here's what I have so far:

Exceptions:
java.lang.Object <-- Throwable<--Exception <-- RuntimeException
java.lang.Object <-- Throwable<--Error

Checked: ClassNotFoundException, DateFormatException, InterruptedException, IOException, NoSuchFieldException, NoSuchMethodException

Unchecked: RuntimeException, ArithmeticException, ClassCastException, IllegalArgumentException<--NumberFormatException, IllegalStateException, IllegalMonitorStateException, IndexOutOfBoundsException<--ArrayIndexOutOfBoundsException, NullPointerException, Error<--AssertionError, Error<--LinkageError<--ExceptionInInitializerError, Error<--VirtualMachineError<--StackOverflowError, Error<--LinkageError<--NoClassDefFoundError.

from Sun:
"Understand which of these are thrown by the virtual machine and recognize situations in which others should be thrown programatically."
I've read the section on this in K&B, and am still fuzzy on the concept, if someone could provide some clarity I'd appreciate that.

thanks
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3714
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The checked exceptions that you should know about for the exam are basically the ones that are part of the API covered in the exam.

For example, since the exam covers I/O, it is imperative that you should know about IOException and FileNotFoundException. Or Thread.sleep -> InterruptedException.

In general, we haven't seen anybody getting a question that required specific knowlegde of any particular exception (except the ones listed in objectives).

Understanding of exceptions is important for determining correct method overriding, try/catch rules, and general program control flow. If a question is testing you on overriding, it will be clear enough for you to know that the base class method is throwing a checked exception. So if you understand that, you don't really need to worry about actual exception classes.
 
Amit Batra
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a table in the K&B on pg 370. the exceptions listed there you will be explicitly tested on. for ex: they could have a question that accesses a bad array index and ask you what kind of exception will be throw.
Then there are some topics where you will be implictly be tested on. In these questions you will just need to look if its been given a try/catch. these are:

1.)whenever you see a file question,
2.) a serialization question,
3.)In threads a JWS question. JWS being a join, wait or sleep.
4.)parsing using dateformat or numberformat.
All the above throw checked exceptions.
Ofcourse you know about assertion errors.
 
Dave Reinhardt
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic