Java Programming 2: Java Exceptions

Java Exceptions

Friday, May 14, 2010

 

1.Arithmetic Exception -These Exception occurs, when you divide a number by zero causes an Arithmetic Exception
2.Class Cast Exception -These Exception occurs, when you try to assign a reference variable of a class to an incompatible reference variable of another class
3.Array Store Exception -These Exception occurs, when you assign an array which is not compatible with the data type of that array
4.Array Index Out Of Bounds Exception -These Exception occurs, when you assign an array which is not compatible with the data type of that array
5.Null Pointer Exception -These Exception occurs, when you try to implement an application without referencing the object and allocating to a memory
6.Number Format Exception -These Exception occurs, when you try to convert a string variable in an incorrect format to integer (numeric format) that is not compatible with each other
7.ClassNotFoundException -This Exception occurs when Java run-time system fail to find the specified class mentioned in the program.
8.Instantiation Exception -This Exception occurs when you create an object of an abstract class and interface
9.Illegal Access Exception -This Exception occurs when you create an object of an abstract class and interface
10.Not Such Method Exception -This Exception occurs when the method you call does not exist in class
11.Negative ArraySizeException -These are Exception, when you declare an array of negative size.
12. Try-catch-finally block
Key aspects about the syntax of the try-catch-finally construct:
– The block notation is mandatory.
– For each try block, there can be one or more catch blocks, but only one finally block.
– The catch blocks and finally blocks must always appear in conjunction with the try block, and in the above order.
– A try block must be followed by AT LEAST one catch block OR one finally block, or both.
– Each catch block defines an exception handle. The header of the catch block takes exactly one argument, which is the exception its block is willing to handle. The exception must be of the Throwable class or one of its subclasses.

0 comments: