What are the ways you can handle exception

Showing Answers 1 - 2 of 2 Answers

ankita

  • Sep 4th, 2005
 

If exceptions are not handled manually by using keywords try,throw,throws and catch, then its automatically handled by the default handler i.e.,the java run-time system. 
try:-The block that has to be monitored for errors is put into this. 
try 

//code to be monitored 

catch:-When the exception is detected by try,its thrown to catch which handles it by figurin out the kinda exception it is. 
catch(Exception_type exception_objectname) 

//handler 

throw:-When the exception is thrown manually to catch,its used 
throws:-Lists the type of exceptions that a method throws. 
 

  Was this answer useful?  Yes

D.S.Reddy

  • Sep 12th, 2005
 

Checked Exceptions must be explicitly handled by the programmer by using try/catch& finally blocks (or) it must be propogated to its callable class.

Unchecked Exceptions may or may not be handled by programmer. The JVM provides the DefaultHandler to handle this type of exceptions

  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