Exception codes in Java | Core Java Tutorials 22.3

This Core Java Tutorials 22.3 “Exception codes in java” is providing some of the example programs to understand how exceptions will raise in java application including NumberFormatException, NullPointerException and many more…



  • Array index starts with 0 to size-1.
  • Accessing elements of array which is out of index results “ArrayIndexOutOfBoundsException”.
  • Following example codes lets you understand clearly….



  • Data conversions will be done at runtime.
  • Invalid data conversions results Runtime Error.
  • Following String to Primitive data conversion explains clearly.



  • Class has both Static and Non static functionality.
  • Non static functionality must be accessed using Object address.
  • Accessing members of with ‘null’ address results NullPointerException.


  • Down casting the Object by providing another class name causes ‘ClassCastException’.
  • Trying to access the data from the file which is not present in the file system ‘FileNotFoundException’.
  • Trying connect with database which is not ready ‘SQLException’.
  • Trying to retrieve IP address of system which is not connection the LAN ‘UnknownHostException’.
Share this