What is throwable and where should we use this?

Showing Answers 1 - 12 of 12 Answers

santh kumar

  • Dec 20th, 2006
 

" Throwable " is a class(it's default super class is Object) in java API. The Throwable class is the superclass of all errors and exceptions in the Java language. Only objects that are instances of this class (or 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. it's a simpe example here. public class ThrowableEx { public static void main(String[] args) { try { System.out.println(" In the Try Block"); int i=10; int j=0; int k=i/j; System.out.println("The value is : " + k); } catch(Throwable e) { System.out.println(" Caught in Throwable class"); } }}

  Was this answer useful?  Yes

mukesh

  • Oct 21st, 2013
 

In the Try Block
Caught in Throwable class

  Was this answer useful?  Yes

Anny

  • Dec 18th, 2015
 

Thorwable is the parent class for error and exception. It is used for exception handling

  Was this answer useful?  Yes

Bikram

  • May 4th, 2016
 

Throwable is the super class for Error and Exception class. Throwable extends Object class. But more often you will not see the user will be extending Throwable. It is used for Handling Exception. But also when you will be catching multiple Exceptions then it is a good idea to implement this one.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions