|
Answer» The exception object is an instance of a subclass of THROWABLE (e.g., java.lang. NullPointerException). It is only available on the error pages. The following table lists out the important methods available in the Throwable class: | 1 | public String getMessage() Returns a detailed message about the exception that has occurred. This message is initialized in the Throwable constructor. |
|---|
| 2 | public Throwable getCause() Returns the cause of the exception as represented by a Throwable object. |
|---|
| 3 | public String toString() Returns the name of the class concatenated with the result of getMessage(). |
|---|
| 4 | public void printStackTrace() PRINTS the result of toString() ALONG with the stack trace to System.err, the error output stream. |
|---|
| 5 | public StackTraceElement [] getStackTrace() Returns an array containing each element on the stack trace. The element at INDEX 0 represents the top of the call stack, and the last element in the array represents the method at the bottom of the call stack. |
|---|
| 6 | public Throwable fillInStackTrace() Fills the stack trace of this Throwable object with the CURRENT stack trace, adding to any previous information in the stack trace. |
|---|
|