Wednesday 10 April 2013

Exceptions in Java precise explanation


1)      The Throwable class is the superclass of all errors and exceptions in the Java language.
a)      Only objects that are instances of this class (or one of its subclasses) are thrown by the Java Virtual Machine or can be thrown by the Java throw statement.

2)      Both the classes Exception and Error is derived from Throwable interface.
3)      All exception classes are subtypes of the java.lang.Exception class.
a)      The two  main subclasses are IOException and RuntimeException.
4)      Errors are not normally trapped form the Java programs.
a)      These conditions normally happen in case of severe failures, which are not handled by the java programs. 
a)      If a method includes code that could cause a checked exception to be thrown then it is checked exception.
b)      Most of the built-in exceptions (e.g., NullPointerException, IndexOutOfBoundsException) are unchecked.

No comments:

Post a Comment