Exception Handling in Java
Exception Handling in Java
Exception Handling in Java
IN JAVA
PR E SENTED BY PR E SENTED TO
NA M E : - A J AY PAT EL E R . M OHIT PAU L
: - A NUJ BHA I PAT EL A S S ISTANT PROF E SSOR
CL A S S : BS C. CS D E PARTM ENT OF CS
ID. NO: - 15 B SC SC04 1
ID. NO: - 15 B S C SC044
S U BJ ECT COD E : - CS IT 423
Define :-Exception
Meaning: Exception is an abnormal condition or unexpected
condition.
Catch:- catch block can handle the exception and handle it.
Program Without exception handling
Program Out put
without exception handling
Program by Exception handling
OUT PUT
Program with exception handling
Finally block
Java finally block is a block that is used to execute
important code such as closing connection,
stream etc.
Java finally block is always executed whether
exception is handled or not.
Java finally block must be followed by try and
catch block .
Java finally Program
where Exception occurs and handled
Throw keyword
Throw keyword is used to explicitly throw an exception.
The throw keyword is mainly used to throw custom
exception
We can throw either checked or unchecked exception in
java by throw keyword.
Syntax of java throw keyword program
C:\Java>java excep 15
exception in thread main java .lang. Arithmetic Exception: not valid to give vote
Throws Keyword