An Exception is an abnormal condition that arises in a code sequence at run time. Exceptions are run time errors. Exceptions generated by the Java are related to the fundamental errors that violate the Java language constraints. All exception classes are subtypes of the java.lang.Exception class. The exception class is a subclass of the Throwable class. Java defines several exception classes inside the standard package java.lang . Some examples of exceptions are ArithmeticException, ArrayIndexOutOfBoundsException, IndexOutOfBoundsException, NullPointerException, NumberFormatException, ClassNotFoundException,etc. When Java Interpreter caught an error such as divide by zero, the interpreter creates an exception object and throws it to inform that an error has occurred. Java has its own exception handling mechanism. It performs the following task: Find the problem – Hit the exception Inform that an error has occurred – Throw the exception Receives the error infor
Comments
Post a Comment