Ex Ception

Exception

 An unwanted unexpected event that disturbs normal flow of the program is called
exception.
Example:
SleepingException
TyrePunchuredException
FileNotFoundException…..etc
· It is highly recommended to handle exceptions. The main objective of exception
handling is graceful (normal) termination of the program.

What is the meaning of exception handling?
· Exception handling doesn’t mean repairing an exception. We have to define alternative
way to continue rest of the program normally this way of “defining alternative is nothing
but exception handling”.

Default exception handling in java:
1) If an exception raised inside any method then the method is responsible to create
Exception object with the following information.
1) Name of the exception.
2) Description of the exception.
3) Location of the exception.
2) After creating that Exception object the method handovers that object to the JVM.
3) JVM checks whether the method contains any exception handling code or not. If
method won’t contain any handling code then JVM terminates that method abnormally
and removes corresponding entry form the stack.
4) JVM identifies the caller method and checks whether the caller method contain any
handling code or not. If the caller method also does not contain handling code then JVM
terminates that caller also abnormally and the removes corresponding entry from the
stack.
5) This process will be continued until main() method and if the main() method also
doesn’t contain any exception handling code then JVM terminates main() method and
removes corresponding entry from the stack.
6) Then JVM handovers the responsibility of exception handling to the default exception
handler.
7) Default exception handler just print exception information to the console in the
following formats and terminates the program abnormally.
Name of exception: description
Location of exception (stack trace)


SHARE

About df

    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment