ExceptionRoot
DRAFT

Misconception:

Class java.lang.Exception is the root of the exception class hierarchy. Thus, the throw statement must throw an object that is of type Exception or a subtype of Exception.

Incorrect

Exception is the top-most exception class

Correct

Correction
Here is what's right.

Wrong! The the root of the exception class hierarchy is class java.lang.Throwable. This class has two subclasses: java.lang.Error and java.lang.Exception.

A throw statement can throw any object o where o instanceof Throwable.

A catch clause can catch any object o where o instanceof Throwable.

The throws clause in a method signature can include any type that is Throwable or a subtype of Throwable.

Language

Java

Concepts

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.