Showing posts with label Exceptions. Show all posts
Showing posts with label Exceptions. Show all posts

Saturday, September 25, 2010

• java.lang.NullPointerException

  • when you call java method on a reference variable that points to null value, then application throws null pointer exception. Here the word pointer is no way related with c and c++ pointers just give dictionary meaning to it that says application is a calling method on a reference variable that points to null value.

• Checked vs. unchecked exception

  • The immediate subclass of java.lang.exception class is called checked exception class. This exception is quite serious exception to catch and handle. The sub classes of java.lang.Runtime exception class are called unchecked exception. If a java method throws checked exception we must catch and handle the exception by using try catch blocks or we must declare to exception to be throws by using throws statement while calling that method. If a java method throws unchecked exception catching and handling that exception or declaring the exception to be thrown is always optional work to do. No exception will come at compile time. The compile time error that comes related to checked exception are not exception they are compile time programmatic and syntactical error. It is always recommended to avoid throws class utilization in the process of dealing with exception because it cannot avoid abnormal program termination in application execution. It is always recommended to use try catch block to catch and handle the exception and to avoid abnormal termination of the application execution when exception is raised. While working with java statement which throws checked or unchecked exception it is recommended to catch and handle exception in the entire situation.

• ClassNotFoundException

  • throws checked exception is calls when given class or interface is not able to load.