The Throwable Class in Java Programming
Previous | Home | Next |
Throwable class is the base class for an entire family of exception classes, declared in java.lang package as java.lang.Throwable.
A throwable contains a snapshot of the execution stack at the time it was created and also a message string that gives more information about the error. This class can be instantiated and thrown by the program.
Thowrable class is divided into two:
1.Exceptions:- Exceptions are thrown if any kind of unusual condition occurs that can be caught. Sometimes it also happens that the exception could not be caught and the program may get terminated.
2.Errors:-- When any kind of serious problem occurs which could not be handled easily like OutOfMemoryError then an error is thrown. Well, errors are not something which is thrown by you rather they are thrown by the Java API or by the Java virtual machine itself i.e. only the exceptions are thrown by your code and not the errors
As you have come to know that exceptions are Objects that means an object is thrown when you throw an exception. Moreover only those objects could be thrown whose classes are derived from Throwable.
Previous | Home | Next |