Home Java Java-exception Exception handling in java
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Exception handling in java

Advertisement
We are going to discus about Exception handling in java. Java program many provides exception. We are handle of error in program when during execution in a program .we are generate of exception try() block and catch() block.

Exception handling in java

We are going to discus about Exception handling in java. Java program many provides exception. We are handle of error in program when during execution in a program .we are generate of exception try() block and catch() block. We are handle of exception checked and unchecked exception. There are many reason of including in exception handling.Thses exception are manly cause by user because user are mistake invalid data entered and invalid operator.

There are two types of exception:-

  • Checked Exception.
  • Unchecked Exception.

Checked Exception

Checked Exception are handle of Exception at compile-time. This exception are object of the exception class. The Checked Exception The Checked Exception are many type.

  • ClassNotFoundException.
  • CloneNotSupportedException.
  • NoSuchFieldException.
  • InterruptedException
  • IIIegalAccessException.
  • NoSuchMethodException.
Checked Exception Reason for Exception
ClassNotFoundException ClassNotFoundException is displayed when java run-time System fails to find the specified class in the program
Instantiation Exception Instantiation Exception is displayed when we have created an object of an abstract class and interface.
IIIegalAccessException

IIIegalAccessException is displayed when we have created an object of an abstract class and Interface.

NoSuchMethodException NOtSuchMethodException is displayed when we have called method but does not exit in class

Unchecked Exception

Unchecked Exception are handle of Exception Runtime. Unchecked Exception are not handle at compile-time but we are handle the runtime. There are many types of handle unchecked Exception handle of compile-time. This Exception displayed due to invalid argument passed to method

  • NumberFormateException.
  • Arithmetic Exception.
  • Array Index Out Of Bounds Exception.
  • NullPointerException.
  • Class Cast Exception
Unchecked Exception Reason for Exception
NumberFormateException
This Exception is displayed, when we are try to convert a string variable in wrong format to integer that is not compatible with each other
Arithmetic Exception
Arithmetic Exception is displayed, when we are divide a number by zero reasons an Arithmetic Exception.
NullPointerException.
NullPointerException exception is displayed when we implement an application without referring to the object and allocating to a memory.
Class Cast Exception
Class Cast Exception is displayed when we try to assign a reference variable of a class to an incompatible reference variable of another class
Array Index Out Of Bounds Exception
Array Index Out Of Bounds Exception is displayed when we assign an array which is not compatible with the data type of that array.
Advertisements

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: May 24, 2013

Related Tutorials

Ask Questions?    Discuss: Exception handling in java  

Post your Comment


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