-ArithmeticExceptionIt is thrown when an exceptional condition has occurred in an arithmetic operation.-ArrayIndexOutOfBoundsExceptionIt is thrown toindicate that an array has been accessed withan illegal index. The index is either negative or greater than or equal tothe size of the array.-ClassNotFoundExceptionThisException is raised when we trytoaccess a class whose definition is not found
-FileNotFoundExceptionThisException is raised when a file is not accessible or does not open.-IOExceptionIt is thrown when an input-output operation failed or interrupted
-InterruptedExceptionIt is thrown when a thread is waiting, sleeping, or doing some processing, and it is interrupted.-NoSuchFieldExceptionIt is thrown when a class does not contain the field (or variable) specified
-NoSuchMethodExceptionIt is thrown when accessing a method which is not found.-NullPointerExceptionThis exception is raised when referring tothe members of a nullobject. Null represents nothing
-NumberFormatExceptionThis exception is raised when a method could not convert a string into a numeric format.-RuntimeExceptionThis represents any exception which occurs during runtime.-StringIndexOutOfBoundsExceptionIt is thrown by Stringclass methods toindicate that an index is either negative or greater than the size of the string
Unchecked:-IndexOutOfBoundsexception(while working witharrays/strings)-NullPointerException(ifI forget toinstantiate the objects)-ArithmaticExceptionChecked:-IOException-SQLException-FileNotFountException
publicclassJavaExceptionExample{publicstaticvoidmain(String args[]){try{//code that may raise exception int data=100/0;}catch(ArithmeticException e){System.out.println(e);}//rest code of the program System.out.println("rest of the code...");}}
In java exception is an object. Exceptions are created when an abnormal
situations are arised in our program. Exceptions can be created by JVM or
by our application code. AllException classes are defined in java.lang.
In otherwords we can say Exception as run time error.
In java exception is an object. Exceptions are created when an abnormal
situations are arised in our program. Exceptions can be created by JVM or
by our application code. AllException classes are defined in java.lang.
In otherwords we can say Exception as run time error. I use try&catch blocks
tohandle any exceptions in my code.
I am familiar withmajor checked and unchecked exceptions and
handle it accordingly tomake my code execution smooth
publicclassJavaExceptionExampleextendsException{publicJavaExceptionExample(){}publicJavaExceptionExample(String s){//String parameter which is the detail message of the exception.}}
Exception is an abnormal condition.
There are mainly two types of exceptions: checked and unchecked.
An error is considered as the unchecked exception. However, according toOracle,
there are three types of exceptions namely:1.CheckedException2.UncheckedException3.Error