NAME :ASIF PATEL SUBJECT : OOPJ Throwable Class
Content 1. What is Throwable class 2. Class Constructors 3. Class Methods 4. Use
What is Throwable class ?  The Throwable class is the superclass of all errors and exceptions in the Java language.  Only objects that are instances of this class (or of one of its subclasses) are thrown by the Java Virtual Machine or can be thrown by the Java throw statement.  Similarly, only this class or one of its subclasses can be the argument type in a catch clause.
• This diagram illustrates the class hierarchy of the Throwable class and its most significant subclasses. • Most programs throw and catch objects that derive from the Exception class. Exceptions indicate that a problem occurred but that the problem is not a serious systemic problem
Class Constructors 1. Throwable() :This constructs a new throwable with null as its detail message.  EX :  O/P :
2. Throwable(String message) : This constructs a new throwable with the specified detail message.  Example :  O/P :
3. Throwable(String message, Throwable cause) : This constructs a new throwable with the specified detail message and cause.  Example :  O/P :
Class Methods 1. getMessage() : Returns the detail message string of this throwable (which may be null). 2. getCause() : Returns the cause of this throwable or null. 3. initCause(Throwable cause) : Initializes the cause of this throwable to the specified value.  EX :
4. getLocalizedMessage() : Creates a localized description of this throwable. Subclasses may override this method in order to produce a locale- specific message.  EX :  O/P :
Use  EX :  O/P :
Thank You

JAVA - Throwable class

  • 1.
    NAME :ASIF PATEL SUBJECT: OOPJ Throwable Class
  • 2.
    Content 1. What isThrowable class 2. Class Constructors 3. Class Methods 4. Use
  • 3.
    What is Throwableclass ?  The Throwable class is the superclass of all errors and exceptions in the Java language.  Only objects that are instances of this class (or of one of its subclasses) are thrown by the Java Virtual Machine or can be thrown by the Java throw statement.  Similarly, only this class or one of its subclasses can be the argument type in a catch clause.
  • 4.
    • This diagram illustratesthe class hierarchy of the Throwable class and its most significant subclasses. • Most programs throw and catch objects that derive from the Exception class. Exceptions indicate that a problem occurred but that the problem is not a serious systemic problem
  • 5.
    Class Constructors 1. Throwable():This constructs a new throwable with null as its detail message.  EX :  O/P :
  • 6.
    2. Throwable(String message): This constructs a new throwable with the specified detail message.  Example :  O/P :
  • 7.
    3. Throwable(String message,Throwable cause) : This constructs a new throwable with the specified detail message and cause.  Example :  O/P :
  • 8.
    Class Methods 1. getMessage(): Returns the detail message string of this throwable (which may be null). 2. getCause() : Returns the cause of this throwable or null. 3. initCause(Throwable cause) : Initializes the cause of this throwable to the specified value.  EX :
  • 9.
    4. getLocalizedMessage() :Creates a localized description of this throwable. Subclasses may override this method in order to produce a locale- specific message.  EX :  O/P :
  • 10.
  • 11.