Our social:

Latest Post

Thursday, 24 March 2016

Exception Handling Part2

Now we are going to continue from last post:
Inside a method if any exception occured the method in which it is raised is responsible to create exception object by including the following information 
1. Name of exception
2. Description of exception
3. Location at which exception occurs(stack trace)

After creating exception object, method handovers that object to the jvm.
JVM will check wether the method contains an exception handling code or not. if the method doesnot contain exception handling code then, JVM terminates that method abnormally and removes crossponding entry from the stack.

Then JVM identifies caller methods and checks wether caller method contains any Exception handling code or not. If the caller method doesnot contain any handling code then JVM terminates tthat caller methods also abnormally and removes the crossponding entery from the stack

This process will be continued until main method, if the main() also doesnt contain handling code the JVM will terminates main() abnormally and removes crossponding entry from the stack also.

Then JVM handovers responsibility of exception handling to DefaultExceptionHandler, which is the part of JVM. DefaultExecptionHandler prints exception information in the following formate and terminates program abnormally.

Wednesday, 23 March 2016

Exception Handling in Java

                                 Exception Handling Part1

An unexcepted unwantaed event that disturbs the normal excution flow of a program is called Exception...

EX--TyrePuncturdeException during travelling, SleepingException during class, FileNotFoundException while file reading...e.t.c

->It is highly recommended to handle exception
The main objective of Exception handling is gracefull or normal termination of program...

To defining an alternative way to continue rest of the program normally while exception comes is the concept of Exception Handling.

Exception handling dosent mean reparing an exception, here we have to provide alternative way to continue rest of the program normally is the concept of Exception Handling.

For example:
our programming requirment is to read data from remote file locating at london at runtime if london file is not available our program should not be terminated abnormally..we have to provide some local file to continue rest of the program normally..this way of defining alternative is nothing but exception handling.

 try{
//Read data from Remote File
//Locating at london
    }catch(FileNotFoundException e){
//use local file & continue
//rest of the program normally
               }

                                                                                              Thank you(Smartyy Sunny)