SlideShare a Scribd company logo
3
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

What's hot (20)

Exception handling
Exception handling
Tata Consultancy Services
 
Java exception handling
Java exception handling
Md. Tanvir Hossain
 
Exception Handling in JAVA
Exception Handling in JAVA
SURIT DATTA
 
Presentation on-exception-handling
Presentation on-exception-handling
Nahian Ahmed
 
Java exception handling ppt
Java exception handling ppt
JavabynataraJ
 
Exception Handling
Exception Handling
Reddhi Basu
 
Exception handling
Exception handling
PhD Research Scholar
 
Exceptionhandling
Exceptionhandling
Nuha Noor
 
Exception Handling In Java
Exception Handling In Java
parag
 
Exception handling in Java
Exception handling in Java
Abhishek Pachisia
 
Test cases
Test cases
Chandra Maddigapu
 
Java - Exception Handling Concepts
Java - Exception Handling Concepts
Victer Paul
 
Exception handling in java
Exception handling in java
Pratik Soares
 
Inner classes in java
Inner classes in java
PhD Research Scholar
 
Exception handling in plsql
Exception handling in plsql
Arun Sial
 
Exception handling in java
Exception handling in java
pooja kumari
 
Exception Handling in C#
Exception Handling in C#
Abid Kohistani
 
Java swing
Java swing
Apurbo Datta
 
Java abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Most Asked Java Interview Question and Answer
Most Asked Java Interview Question and Answer
TOPS Technologies
 
Exception Handling in JAVA
Exception Handling in JAVA
SURIT DATTA
 
Presentation on-exception-handling
Presentation on-exception-handling
Nahian Ahmed
 
Java exception handling ppt
Java exception handling ppt
JavabynataraJ
 
Exception Handling
Exception Handling
Reddhi Basu
 
Exceptionhandling
Exceptionhandling
Nuha Noor
 
Exception Handling In Java
Exception Handling In Java
parag
 
Java - Exception Handling Concepts
Java - Exception Handling Concepts
Victer Paul
 
Exception handling in java
Exception handling in java
Pratik Soares
 
Exception handling in plsql
Exception handling in plsql
Arun Sial
 
Exception handling in java
Exception handling in java
pooja kumari
 
Exception Handling in C#
Exception Handling in C#
Abid Kohistani
 
Java abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Most Asked Java Interview Question and Answer
Most Asked Java Interview Question and Answer
TOPS Technologies
 

Similar to Exception Handling in Java (20)

Exception Handling.pptx
Exception Handling.pptx
primevideos176
 
Lec-01 Exception Handling in Java_javatpoint.pptx
Lec-01 Exception Handling in Java_javatpoint.pptx
MdNazmulHasanRuhan1
 
Exception handling in java
Exception handling in java
chauhankapil
 
exception handling in java.ppt
exception handling in java.ppt
Varshini62
 
oop-unit-iii-ppt.pptexceptionhandlingobjectorientedprogramming
oop-unit-iii-ppt.pptexceptionhandlingobjectorientedprogramming
ssuserf45a65
 
UNIT-3.pptx Exception Handling and Multithreading
UNIT-3.pptx Exception Handling and Multithreading
SakkaravarthiS1
 
VTU MCA 2022 JAVA Exceeption Handling.docx
VTU MCA 2022 JAVA Exceeption Handling.docx
Poornima E.G.
 
Exception Handling Multithreading: Fundamental of Exception; Exception types;...
Exception Handling Multithreading: Fundamental of Exception; Exception types;...
poongothai11
 
Ch-1_5.pdf this is java tutorials for all
Ch-1_5.pdf this is java tutorials for all
HayomeTakele
 
unit 4 msbte syallbus for sem 4 2024-2025
unit 4 msbte syallbus for sem 4 2024-2025
AKSHAYBHABAD5
 
Exception handling in java
Exception handling in java
pooja kumari
 
Exception handling basic
Exception handling basic
TharuniDiddekunta
 
Exceptionhandling
Exceptionhandling
DrHemlathadhevi
 
Exception handling in java.pptx
Exception handling in java.pptx
Nagaraju Pamarthi
 
Exception handling in java
Exception handling in java
Kavitha713564
 
Exceptions overview
Exceptions overview
Bharath K
 
Exception Handling s the process of responding to unwanted or unexpected even...
Exception Handling s the process of responding to unwanted or unexpected even...
jhgasdjkfsadjkfh
 
Java Exception Handling & IO-Unit-3 (1).ppt
Java Exception Handling & IO-Unit-3 (1).ppt
SahilKumar542
 
Java Exception Handling & IO-Unit-3 (1).ppt
Java Exception Handling & IO-Unit-3 (1).ppt
SahilKumar542
 
Java chapter 6
Java chapter 6
Abdii Rashid
 
Exception Handling.pptx
Exception Handling.pptx
primevideos176
 
Lec-01 Exception Handling in Java_javatpoint.pptx
Lec-01 Exception Handling in Java_javatpoint.pptx
MdNazmulHasanRuhan1
 
Exception handling in java
Exception handling in java
chauhankapil
 
exception handling in java.ppt
exception handling in java.ppt
Varshini62
 
oop-unit-iii-ppt.pptexceptionhandlingobjectorientedprogramming
oop-unit-iii-ppt.pptexceptionhandlingobjectorientedprogramming
ssuserf45a65
 
UNIT-3.pptx Exception Handling and Multithreading
UNIT-3.pptx Exception Handling and Multithreading
SakkaravarthiS1
 
VTU MCA 2022 JAVA Exceeption Handling.docx
VTU MCA 2022 JAVA Exceeption Handling.docx
Poornima E.G.
 
Exception Handling Multithreading: Fundamental of Exception; Exception types;...
Exception Handling Multithreading: Fundamental of Exception; Exception types;...
poongothai11
 
Ch-1_5.pdf this is java tutorials for all
Ch-1_5.pdf this is java tutorials for all
HayomeTakele
 
unit 4 msbte syallbus for sem 4 2024-2025
unit 4 msbte syallbus for sem 4 2024-2025
AKSHAYBHABAD5
 
Exception handling in java
Exception handling in java
pooja kumari
 
Exception handling in java.pptx
Exception handling in java.pptx
Nagaraju Pamarthi
 
Exception handling in java
Exception handling in java
Kavitha713564
 
Exceptions overview
Exceptions overview
Bharath K
 
Exception Handling s the process of responding to unwanted or unexpected even...
Exception Handling s the process of responding to unwanted or unexpected even...
jhgasdjkfsadjkfh
 
Java Exception Handling & IO-Unit-3 (1).ppt
Java Exception Handling & IO-Unit-3 (1).ppt
SahilKumar542
 
Java Exception Handling & IO-Unit-3 (1).ppt
Java Exception Handling & IO-Unit-3 (1).ppt
SahilKumar542
 
Ad

More from Java2Blog (7)

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

Recently uploaded (20)

How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
 
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Revista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
Overview of Off Boarding in Odoo 18 Employees
Overview of Off Boarding in Odoo 18 Employees
Celine George
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
Paper 109 | Archetypal Journeys in ‘Interstellar’: Exploring Universal Themes...
Paper 109 | Archetypal Journeys in ‘Interstellar’: Exploring Universal Themes...
Rajdeep Bavaliya
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
Overview of Employee in Odoo 18 - Odoo Slides
Overview of Employee in Odoo 18 - Odoo Slides
Celine George
 
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
 
BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...
Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...
Himalayan Group of Professional Institutions (HGPI)
 
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
 
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Revista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
Overview of Off Boarding in Odoo 18 Employees
Overview of Off Boarding in Odoo 18 Employees
Celine George
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
Paper 109 | Archetypal Journeys in ‘Interstellar’: Exploring Universal Themes...
Paper 109 | Archetypal Journeys in ‘Interstellar’: Exploring Universal Themes...
Rajdeep Bavaliya
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
Overview of Employee in Odoo 18 - Odoo Slides
Overview of Employee in Odoo 18 - Odoo Slides
Celine George
 
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
 
BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 

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.