Janeice DelVecchio wrote:Okay, so I understand that a checked exception results in a compile time error, and unchecked exceptions result in runtime errors.
I think I understand why (because the compiler "checks" for the checked exceptions... if you're running, you've been checked?).....
Checked exception- Are thrown when the program is executing and they need to be supported by
throws clause or the
try...catch block. Any attempts to compile the code without any of these-
throws/try...catch for Checked exceptions would result in a compiler error. But Checked exceptions itself don't result in a compile time error.
Same goes with Unchecked exceptions- These need not be handled by the code as they are usually unexpected errors/exceptions. This
link briefly explains the two.
Janeice DelVecchio wrote:
I remember the common runtime exceptions.... null pointer, class cast, arithmetic. And the common compiler time exceptions.... IO, class/method not found, SQL.
Now I'm looking at the API. There's like fifty of each. How many of these do I really need to know? I mean, is UnsupportedFlavorException really on the exam (I know the compiler hates cherry flavor, but come on!)?
I have the K&B SCJP6 book.... I just can't find any list of ones I need to memorize. And I'm not sure how much is extensive API memorization versus just knowing conceptually which one is going to cause a compile/run time error (and thus which needs to be caught).
Any tips?
From the Objectives in the Flow Control Section:
Section 2 Flow Control wrote: Recognize situations that will result in any of the following being thrown: ArrayIndexOutOfBoundsException,ClassCastException, IllegalArgumentException, IllegalStateException, NullPointerException, NumberFormatException, AssertionError, ExceptionInInitializerError, StackOverflowError or NoClassDefFoundError. Understand which of these are thrown by the virtual machine and recognize situations in which others should be thrown programatically.
So I think one has to know these exceptions. There would be questions which relate to which exception might be thrown or to categorize the exceptions as Unchecked/Checked.