SlideShare a Scribd company logo
2
Most read
4
Most read
8
Most read
www.java2blog.com
EXCEPTION HANDLING
CONTENT
Introduction
Types of Exception Handling
try block
catch block
finally block
throw vs throws
INTRODUCTION
An exception is an abnormal condition which occurs
during the execution of a program. To handle the
Exception we use exception handling mechanism.
Exception handling helps to maintain the normal flow
of execution of an application.
TYPES OF EXCEPTION
An exception that is checked at compile time is
known as checked Exceptions. Examples of
Checked Exception are IOException,
SQLException, ClassNotFoundException.
Checked Exception:
TYPES OF EXCEPTION
An exception that is not checked at compile time is
known as an unchecked exception. Examples of
Unchecked Exception are ArithmeticException,
NullPointerException, NumberFormatException.
Unchecked Exception:
TYPES OF EXCEPTION
Errors are irrecoverable.
Exa- VirtualMachineError,
StackOverFlowError,
OutOfMemoryError.
Error:
TRY BLOCK
It must be followed either by finally block or
Catch block.
It must be used within a method.
Try block is used to wrap the code that may throw
an exception.
CATCH BLOCK
A catch block can be used only after the try
block.
All the catch block must be ordered from subclass
exception to super class exception.
The catch block is used to handle the exception.
multiple catch block can be within a single try block.
FINALLY BLOCK
We put the cleanup code into the finally
block like closing a file.
A finally block will not execute only when If the
program terminates through System.exit() or If
causing a fatal error.
A finally block is executed always whether the
exception is handled or not.
THROW VS THROWS
throws keyword is used to declare an exception. It
provides information to the programmer that there may
occur an exception so It is programmer’s responsibility
to provide exception handler so that the normal flow of
application can be maintained
throw keyword is used to explicitly throw an exception.
It is generally used to throw a custom exception (User
defined exception). It is used within a method body.
www.java2blog.com
THANK YOU

More Related Content

PDF
Java exception handling ppt
PPTX
L14 exception handling
PPTX
Exception handling
PPT
Exception handling
PPSX
Exception Handling
PPTX
Exception Handling in Java
PPTX
Java exception handling
PPTX
Exception handling in Java
Java exception handling ppt
L14 exception handling
Exception handling
Exception handling
Exception Handling
Exception Handling in Java
Java exception handling
Exception handling in Java

What's hot (20)

PPTX
Java exception handling
PPT
exception handling in java.ppt
PDF
Java - Exception Handling Concepts
PDF
Polymorphism In Java
PPTX
Exceptionhandling
PPTX
Exception handling in java
PPTX
Operators in java
PDF
Java 8 Lambda Expressions
PPT
Exception Handling in JAVA
PPT
Exception handling
PDF
Java variable types
PPTX
Exception handling in Java
PPS
Java Exception handling
PPTX
WHAT IS ABSTRACTION IN JAVA
PPTX
Object Oriented Programing JAVA presentaion
PPTX
Java packages
PPTX
Methods in java
PPTX
PDF
Generics
Java exception handling
exception handling in java.ppt
Java - Exception Handling Concepts
Polymorphism In Java
Exceptionhandling
Exception handling in java
Operators in java
Java 8 Lambda Expressions
Exception Handling in JAVA
Exception handling
Java variable types
Exception handling in Java
Java Exception handling
WHAT IS ABSTRACTION IN JAVA
Object Oriented Programing JAVA presentaion
Java packages
Methods in java
Generics
Ad

Similar to Exception Handling in Java (20)

PPTX
Exception handling2.0.pptx
PPT
Exception handling
PPTX
Exception Handling computer science concept java
PPTX
130410107010 exception handling
PPTX
Exception handling in java
PPTX
Exception handling in java.pptx
PPTX
Exception-Handling-in-Java-A-Comprehensive-Guide (1).pptx
PPTX
Exception handling in java-PPT.pptx
PPTX
Exceptions handling in java
PPTX
Module 4-1.pptx
PDF
Ch-1_5.pdf this is java tutorials for all
PPTX
Exception handling in JAVA
ODP
Exception handling in java
PPT
Exceptionhandling
PPTX
presentation-on-exception-handling-160611180456 (1).pptx
PPTX
presentation-on-exception-handling 1.pptx
PPTX
presentationon exception handling in java.pptx
PPTX
Exception handling in java
Exception handling2.0.pptx
Exception handling
Exception Handling computer science concept java
130410107010 exception handling
Exception handling in java
Exception handling in java.pptx
Exception-Handling-in-Java-A-Comprehensive-Guide (1).pptx
Exception handling in java-PPT.pptx
Exceptions handling in java
Module 4-1.pptx
Ch-1_5.pdf this is java tutorials for all
Exception handling in JAVA
Exception handling in java
Exceptionhandling
presentation-on-exception-handling-160611180456 (1).pptx
presentation-on-exception-handling 1.pptx
presentationon exception handling in java.pptx
Exception handling in java
Ad

More from Java2Blog (7)

PDF
Java interview questions
PDF
Core Java Tutorial
PDF
Java String
PDF
Polymorphism in Java
PDF
Spring Tutorial for Beginners
PDF
Web Service Tutorial
PDF
How to Learn Java Programming
Java interview questions
Core Java Tutorial
Java String
Polymorphism in Java
Spring Tutorial for Beginners
Web Service Tutorial
How to Learn Java Programming

Recently uploaded (20)

PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Classroom Observation Tools for Teachers
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Trump Administration's workforce development strategy
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Cell Types and Its function , kingdom of life
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
Cell Structure & Organelles in detailed.
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
O5-L3 Freight Transport Ops (International) V1.pdf
Anesthesia in Laparoscopic Surgery in India
Chinmaya Tiranga quiz Grand Finale.pdf
Classroom Observation Tools for Teachers
FourierSeries-QuestionsWithAnswers(Part-A).pdf
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Trump Administration's workforce development strategy
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Final Presentation General Medicine 03-08-2024.pptx
Supply Chain Operations Speaking Notes -ICLT Program
202450812 BayCHI UCSC-SV 20250812 v17.pptx
O7-L3 Supply Chain Operations - ICLT Program
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
GDM (1) (1).pptx small presentation for students
Cell Types and Its function , kingdom of life
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Cell Structure & Organelles in detailed.
Pharmacology of Heart Failure /Pharmacotherapy of CHF

Exception Handling in Java

  • 2. CONTENT Introduction Types of Exception Handling try block catch block finally block throw vs throws
  • 3. INTRODUCTION An exception is an abnormal condition which occurs during the execution of a program. To handle the Exception we use exception handling mechanism. Exception handling helps to maintain the normal flow of execution of an application.
  • 4. TYPES OF EXCEPTION An exception that is checked at compile time is known as checked Exceptions. Examples of Checked Exception are IOException, SQLException, ClassNotFoundException. Checked Exception:
  • 5. TYPES OF EXCEPTION An exception that is not checked at compile time is known as an unchecked exception. Examples of Unchecked Exception are ArithmeticException, NullPointerException, NumberFormatException. Unchecked Exception:
  • 6. TYPES OF EXCEPTION Errors are irrecoverable. Exa- VirtualMachineError, StackOverFlowError, OutOfMemoryError. Error:
  • 7. TRY BLOCK It must be followed either by finally block or Catch block. It must be used within a method. Try block is used to wrap the code that may throw an exception.
  • 8. CATCH BLOCK A catch block can be used only after the try block. All the catch block must be ordered from subclass exception to super class exception. The catch block is used to handle the exception. multiple catch block can be within a single try block.
  • 9. FINALLY BLOCK We put the cleanup code into the finally block like closing a file. A finally block will not execute only when If the program terminates through System.exit() or If causing a fatal error. A finally block is executed always whether the exception is handled or not.
  • 10. THROW VS THROWS throws keyword is used to declare an exception. It provides information to the programmer that there may occur an exception so It is programmer’s responsibility to provide exception handler so that the normal flow of application can be maintained throw keyword is used to explicitly throw an exception. It is generally used to throw a custom exception (User defined exception). It is used within a method body.