GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java
Go To First  |  Previous Question  |  Next Question 
 Core Java  |  Question 462 of 493    Print  
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?


  
Total Answers and Comments: 3 Last Update: February 20, 2008     Asked by: sha_kr2001 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: nithya_k
 

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.



Above answer was rated as good by the following members:
interviewprep9
December 25, 2007 00:39:18   #1  
nithya_k Member Since: November 2007   Contribution: 1    

RE: How to catch an Error occurred in a class

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.


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
January 08, 2008 02:12:31   #2  
onelastman Member Since: December 2007   Contribution: 6    

RE: How to catch an Error occurred in a class
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.

 
Is this answer useful? Yes | No
February 20, 2008 06:33:47   #3  
sampra Member Since: February 2008   Contribution: 279    

RE: How to catch an Error occurred in a class
we can handle the exception but we cabt handle error super call of both is throwable
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape