How to catch an Error occurred in a class

Can we catch an Error occurred in a class by extending that class with Throwable Since, Exception and error is the sub class of throwable.If yes/no- why?

Questions by sha_kr2001   answers by sha_kr2001

Showing Answers 1 - 0 of 0 Answers

nithya_k

  • Dec 25th, 2007
 

Errors can be caught just like how we catch exceptions.Error is a subclass of Throwable.

Classes that derive from Error represent unusual situations that are not caused by program errors, and indicate things that would not normally happen during program execution, such as the JVM running out of memory. Generally, your application won't be able to recover from an Error, so you're not required to handle them. If your code does not handle them (and it usually won't), it will still compile with no trouble.

onelastman

  • Jan 8th, 2008
 

yes...u can handle that error by extending with our  class with throwable...

but it is not recommended to do...pls don't consider errors as same to the exceptions..

both are different...Errors are very serious type of exceptions that you are not supposed to handle them.....actually jvm handles the Errors....
if you try to catch the errors..then jvm will not catch them..
this may even result in the collapse of JVM.

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