vivarem logo
/ Vivarem / Computers and IT / IT Education / online / tutorial / Java / OOP / 9 /
There are 0 sub sections

You can add Your Link here with New Link
Java Object Oriented Programming - 9

Exception Handling
It is common that exceptions occur during runtime of any program, This is the case with java also.
try{
}catch(Exception e){
} finally{
}
Any statement that throws an Exception is enclosed within try {}block. In the catch statement we will put in the code of how to handle when exception occured.Finaly block contain statements that must be executed on all situations ie wheather or not exception occured. Not catching exception may cause compiler errors or runtime errors in some cases;All Exceptions are derived from the Base class Exception. In serialisation we will discuss handling Exceptions. If You don't want the method in which exception occured to be handled the you may throw the exception using throws ExceptionName statment The Exception class which is ase of all other Exception classes implements Throwable interface.

Example
public void show() throws Exception{
}
Example Creating New Exception Class
public class MyNewException extends Exception{
public MyNewException(String Message){
super(Message);
}
}

< Abstract Classes and interfaces |
Content |
Serialization and miscellaneous topics >


You can Add a Classified here with New Classified