Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Beginners Different types of exception handling in Java

 
 

Share on Google+Share on Google+

Different types of exception handling in Java

Advertisement
java.lang.Exception class is the base class for Java exception handling. And it contains many other subclasses to handle different types of exceptions in Java programming like RuntimeException, ClassNotFoundException and ParseException etc. So, this tutorial is taking about exceptions, why they occurs and how to handle such kinds of exceptions in Java Programming.

Different types of exception handling in Java

Mostly an error or exception in java occurs due to programming error, client code error or due to resource failures in applications. In this tutorial, we are talking about the nature and types of exceptions in Java.

There are basically two types of errors , compile time and run-time.

The compile time error occurs, when the defined syntax of the program is wrong or somthing left incomplete. For example if your code missed the code terminater(;) or the sytax of writing method or class is wrong then in such cases your program can throw a compile time error.

A compile time error occurs at the time of compilation and it restrict program to be execute.

Where as a Run-time Error occurs at the time of executing code. The base class for Runtime exception class is java.lang.RuntimeException that contains several other methods to handle runtime exceptions. Few examples of Java run time exceptions are NullPointerException, SecurityException, SystemException, JMRuntimeException and WebServiceException etc.

A RunTime exception can occurs due to null pointer, out of bound array access or also in case if the file is not found.

Exception Hierarchy:

See the image given below that explains the flow of exception hierarchy:

Exception handling

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 2, 2013

Related Tutorials

Discuss: Different types of exception handling in Java  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com