Exception Handling in java programming

Spread the love

Exception Handling

A java exception is an object that describe an error condition that has occurred in a piece of code.

The compilation of code is executed properly but when we compile the code that was error occurred below

Excepyion error in java

Exception error in java

This type of error managed by Java exception handling.
There are five keyword to manage the error
try,catch,throw,throws and finally
Program statements that we want to monitor for exception are contained within try block
If exception occur in try block than is pass by thrown keyword
The code treat by the catch keyword.
System generated exceptions are automatically thrown by the java run time system
For manually thrown an exception,we use the keyword throw
Any exception that is thrown out of a method must be specified as such by a throws clause
Any code that absolutely must be executed after a try block completes is put in a finally block
Example for overcome exception using try catch:-

In the code exception error is enclose in the try block,following a catch clause is specifies the exception type that we want to catch.in the catch clause our solution is specified.

Pravesh Kumar

Leave a Reply

Your email address will not be published. Required fields are marked *