I would like to have a very DETAILED answer to why the excep

I would like to have a very DETAILED answer to why the exception handling mechanism exists and how it works?

Thanks.

Solution

An Exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program\'s instructions. An exception can occur for many different reasons. These are some reasons.

File that needs to be opened cannot be found.

A network connection has been lost in the middle of communications or the JVM has run out of memory.

To handle the exceptions raised during the runtime a mechanism is needed. That mechanism is called exception handling mechanism.

When an error occurs within a method, the method creates an object and hands it off to the runtime system called an exception object, contains information about the error, including its type and the state of the program when the error occurred. Creating an exception object and handing it to the runtime system is called throwing an exception. After a method throws an exception, the runtime system attempts to find something to handle it. The runtime system searches the call stack for a method that contains a block of code that can handle the exception. This block of code is called an exception handler. The exception handler cathes the exception which is thrown and handles so that the program execution does not get interrupted.

I would like to have a very DETAILED answer to why the exception handling mechanism exists and how it works? Thanks.SolutionAn Exception is an event, which occu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site