The class Exception is the superclass of all the exceptions that ordinary programs may wish to recover from. The class RuntimeException is a subclass of class Exception. The subclasses of RuntimeException are unchecked exception classes. The subclasses of Exception other than RuntimeException are all checked exception classes.
Errors classes and their part in the exceptions will be discussed seperately in the coming posts.
I hope with the help figure you might have totally understood the hierrachy of Exceptions.
Checked Exceptions:Checked Exceptions are instances of Exception classes or one of its sub-classes excluding the branch of Runtime Exceptions.Any checked exceptions that may be thrown in a method must either be caught or declared in the method's throws clause.
They are called as Checked Exceptions because the Compiler and JVM check to make sure that either it is caught or declared in the method.
RunTime Exceptions: RuntimeException also extends from Exception. However, all of the exceptions that inherit from RuntimeException get special treatment. There is no requirement for the client code to deal with them, and hence they are called unchecked exceptions.
Examples of Runtime Exceptions include NullPointer,ArrayIndexOutOFBounds etc.
Is exception the the superclass or throwable class the super class.
ReplyDeleteThrowable class is the super class.But here in the current post i have started my discussion with exception class.
ReplyDelete