Explain me what are the important methods of Java Exception Class?

Submitted by: Muhammad
Methods are defined in the base class Throwable. Some of the important methods of Java exception class are stated below.

☛ String getMessage() – This method returns the message String about the exception . The message can be provided through its constructor.
☛ public StackTraceElement[] getStackTrace() – This method returns an array containing each element on the stack trace. The element at index 0 represents the top of the call stack whereas the last element in the array represents the method at the bottom of the call stack.
☛ Synchronized Throwable getCause() – This method returns the cause of the exception or null id as represented by a Throwable object.
☛ String toString() – This method returns the information in String format. The returned String contains the name of Throwable class and localized message.
☛ void printStackTrace() – This method prints the stack trace information to the standard error stream.
Submitted by: Muhammad

Read Online Sr.Java Web Developer Job Interview Questions And Answers