Answers

Question and Answer:

  Home  Sr.Java Web Developer

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

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.

 165 views

More Questions for you: