This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Originally posted by Jacky Zhang: How many of these are checked exceptions? How is checked exception defined?
A runtime exception is an exception that IS-A RuntimeException -- meaning an object that is either that class type or subclass of that type.
The significance of the RuntimeException class is that the compiler will not require you to declare that you throw that exception, or require you to catch it. It is basically an "unchecked" exception.
A "checked" exception is an exception that is not an "unchecked" exception -- or an exception that is not a RuntimeException.
[EDIT: new text below]
Just realize that this thread also refers to errors.
An Error is a throwable object that IS-A Error -- meaning an object that is either that class type or subclass of that type.
Like runtime exceptions, it is also unchecked. However, it is separated from runtime exceptions because it is *not* recommended that you catch these, as they generally indicate an abnormal condition that may not be recoverable.
Henry [ September 20, 2006: Message edited by: Henry Wong ]
Hi Jacky, "Are programmatic exceptions all runtime exceptions?" It depends : There is an actual class called RuntimeException. If a particular exception entends this, then it is a runtime exception. Examples include ArrayIndexOutOfBoundsException & NullPointerException. There are not checked exceptions in that they dont need to be declared as a possible exception that could be thrown from a method. Similarly the dont need to be handled by the calling method with an explicit catch or declare.