SlideShare una empresa de Scribd logo
1 de 6
TYPE OF EXCEPTIONS
Chapter 9.4:
Objectives
 After you have read and studied this
chapter, you should be able to
 Improve the reliability of code by
incorporating exception-handling.
 Implement the try-catch blocks for catching
and handling exceptions.
 Write methods that propagate exceptions.
 Distinguish the checked and unchecked, or
runtime, exceptions.
Checked vs. Unchecked Exception
 There are two types of exceptions:
 Checked.
 Unchecked.
 A checked exception is an exception that is
checked at compile time, so it must be
handled.
 An unchecked exception is not checked at
compile time, so no need to handle
(optional).
 unchecked exception include Error and
RuntimeException and their subclasses.
 checked exception include Exception and
its subclasses.
Different Handling Rules
 When calling a method that can throw
checked exceptions
 use the try-catch statement and place the call
in the try block, or
 modify the method header to include the
appropriate throws clause.
 When calling a method that can throw
runtime exceptions, it is optional to use the
try-catch statement or modify the method
header to include a throws clause.
Handling Checked
Exceptions
Handling Runtime
Exceptions

Más contenido relacionado

La actualidad más candente (7)

Control statements
Control statementsControl statements
Control statements
 
Python exception handling
Python   exception handlingPython   exception handling
Python exception handling
 
Java unit 11
Java unit 11Java unit 11
Java unit 11
 
Select case
Select caseSelect case
Select case
 
Decision making
Decision makingDecision making
Decision making
 
Vb decision making statements
Vb decision making statementsVb decision making statements
Vb decision making statements
 
Exception
ExceptionException
Exception
 

Destacado

Chapter 9.1
Chapter 9.1Chapter 9.1
Chapter 9.1
sotlsoc
 
Chapter 3.4
Chapter 3.4Chapter 3.4
Chapter 3.4
sotlsoc
 
Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5
sotlsoc
 
Chapter 3.1
Chapter 3.1Chapter 3.1
Chapter 3.1
sotlsoc
 
Chapter 5.1
Chapter 5.1Chapter 5.1
Chapter 5.1
sotlsoc
 
Chapter 11.2
Chapter 11.2Chapter 11.2
Chapter 11.2
sotlsoc
 
Chapter 2.2
Chapter 2.2Chapter 2.2
Chapter 2.2
sotlsoc
 
Chapter 10.3
Chapter 10.3Chapter 10.3
Chapter 10.3
sotlsoc
 
Chapter 8.2
Chapter 8.2Chapter 8.2
Chapter 8.2
sotlsoc
 
Chapter 10.1
Chapter 10.1Chapter 10.1
Chapter 10.1
sotlsoc
 
Chapter 7.4
Chapter 7.4Chapter 7.4
Chapter 7.4
sotlsoc
 
Chapter 1.0 new
Chapter 1.0 newChapter 1.0 new
Chapter 1.0 new
sotlsoc
 
Chapter 6.1
Chapter 6.1Chapter 6.1
Chapter 6.1
sotlsoc
 
Chapter 11.4
Chapter 11.4Chapter 11.4
Chapter 11.4
sotlsoc
 
Chapter 8.0
Chapter 8.0Chapter 8.0
Chapter 8.0
sotlsoc
 
Chapter 5.0
Chapter 5.0Chapter 5.0
Chapter 5.0
sotlsoc
 
Chapter 9.2
Chapter 9.2Chapter 9.2
Chapter 9.2
sotlsoc
 
Chapter 9.0
Chapter 9.0Chapter 9.0
Chapter 9.0
sotlsoc
 
Chapter 1.2
Chapter 1.2Chapter 1.2
Chapter 1.2
sotlsoc
 

Destacado (19)

Chapter 9.1
Chapter 9.1Chapter 9.1
Chapter 9.1
 
Chapter 3.4
Chapter 3.4Chapter 3.4
Chapter 3.4
 
Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5
 
Chapter 3.1
Chapter 3.1Chapter 3.1
Chapter 3.1
 
Chapter 5.1
Chapter 5.1Chapter 5.1
Chapter 5.1
 
Chapter 11.2
Chapter 11.2Chapter 11.2
Chapter 11.2
 
Chapter 2.2
Chapter 2.2Chapter 2.2
Chapter 2.2
 
Chapter 10.3
Chapter 10.3Chapter 10.3
Chapter 10.3
 
Chapter 8.2
Chapter 8.2Chapter 8.2
Chapter 8.2
 
Chapter 10.1
Chapter 10.1Chapter 10.1
Chapter 10.1
 
Chapter 7.4
Chapter 7.4Chapter 7.4
Chapter 7.4
 
Chapter 1.0 new
Chapter 1.0 newChapter 1.0 new
Chapter 1.0 new
 
Chapter 6.1
Chapter 6.1Chapter 6.1
Chapter 6.1
 
Chapter 11.4
Chapter 11.4Chapter 11.4
Chapter 11.4
 
Chapter 8.0
Chapter 8.0Chapter 8.0
Chapter 8.0
 
Chapter 5.0
Chapter 5.0Chapter 5.0
Chapter 5.0
 
Chapter 9.2
Chapter 9.2Chapter 9.2
Chapter 9.2
 
Chapter 9.0
Chapter 9.0Chapter 9.0
Chapter 9.0
 
Chapter 1.2
Chapter 1.2Chapter 1.2
Chapter 1.2
 

Similar a Chapter 9.4

Exception Handling_ Mastering the Art of Dealing with Errors and Exceptions.pdf
Exception Handling_ Mastering the Art of Dealing with Errors and Exceptions.pdfException Handling_ Mastering the Art of Dealing with Errors and Exceptions.pdf
Exception Handling_ Mastering the Art of Dealing with Errors and Exceptions.pdf
RamirezCarl
 
Multi catch statement
Multi catch statementMulti catch statement
Multi catch statement
myrajendra
 
Types of exceptions
Types of exceptionsTypes of exceptions
Types of exceptions
myrajendra
 
Python Programming - X. Exception Handling and Assertions
Python Programming - X. Exception Handling and AssertionsPython Programming - X. Exception Handling and Assertions
Python Programming - X. Exception Handling and Assertions
Ranel Padon
 
Ch-1_5.pdf this is java tutorials for all
Ch-1_5.pdf this is java tutorials for allCh-1_5.pdf this is java tutorials for all
Ch-1_5.pdf this is java tutorials for all
HayomeTakele
 
Uvm cookbook-systemverilog-guidelines-verification-academy
Uvm cookbook-systemverilog-guidelines-verification-academyUvm cookbook-systemverilog-guidelines-verification-academy
Uvm cookbook-systemverilog-guidelines-verification-academy
Raghavendra Kamath
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
priyankazope
 

Similar a Chapter 9.4 (20)

Javasession4
Javasession4Javasession4
Javasession4
 
Exception Handling_ Mastering the Art of Dealing with Errors and Exceptions.pdf
Exception Handling_ Mastering the Art of Dealing with Errors and Exceptions.pdfException Handling_ Mastering the Art of Dealing with Errors and Exceptions.pdf
Exception Handling_ Mastering the Art of Dealing with Errors and Exceptions.pdf
 
SUBHASH.pptx
SUBHASH.pptxSUBHASH.pptx
SUBHASH.pptx
 
Multi catch statement
Multi catch statementMulti catch statement
Multi catch statement
 
Types of exceptions
Types of exceptionsTypes of exceptions
Types of exceptions
 
Exception Handling In Java
Exception Handling In JavaException Handling In Java
Exception Handling In Java
 
OCAJP 8
OCAJP 8OCAJP 8
OCAJP 8
 
31 days Refactoring
31 days Refactoring31 days Refactoring
31 days Refactoring
 
UNIT III 2021R.pptx
UNIT III 2021R.pptxUNIT III 2021R.pptx
UNIT III 2021R.pptx
 
UNIT III 2021R.pptx
UNIT III 2021R.pptxUNIT III 2021R.pptx
UNIT III 2021R.pptx
 
Java Exceptions and Exception Handling
 Java  Exceptions and Exception Handling Java  Exceptions and Exception Handling
Java Exceptions and Exception Handling
 
Java chapter 6
Java chapter 6Java chapter 6
Java chapter 6
 
Python Programming - X. Exception Handling and Assertions
Python Programming - X. Exception Handling and AssertionsPython Programming - X. Exception Handling and Assertions
Python Programming - X. Exception Handling and Assertions
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
VTU MCA 2022 JAVA Exceeption Handling.docx
VTU MCA  2022 JAVA Exceeption Handling.docxVTU MCA  2022 JAVA Exceeption Handling.docx
VTU MCA 2022 JAVA Exceeption Handling.docx
 
Ch-1_5.pdf this is java tutorials for all
Ch-1_5.pdf this is java tutorials for allCh-1_5.pdf this is java tutorials for all
Ch-1_5.pdf this is java tutorials for all
 
Object Oriented Programming C#
Object Oriented Programming C#Object Oriented Programming C#
Object Oriented Programming C#
 
Uvm cookbook-systemverilog-guidelines-verification-academy
Uvm cookbook-systemverilog-guidelines-verification-academyUvm cookbook-systemverilog-guidelines-verification-academy
Uvm cookbook-systemverilog-guidelines-verification-academy
 
Exception handling in .net
Exception handling in .netException handling in .net
Exception handling in .net
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 

Más de sotlsoc

Chapter 2.0 new
Chapter 2.0 newChapter 2.0 new
Chapter 2.0 new
sotlsoc
 
Chapter 3.0 new
Chapter 3.0 newChapter 3.0 new
Chapter 3.0 new
sotlsoc
 
Chapter 6.5 new
Chapter 6.5 newChapter 6.5 new
Chapter 6.5 new
sotlsoc
 
Chapter 11.1
Chapter 11.1Chapter 11.1
Chapter 11.1
sotlsoc
 
Chapter 11.3
Chapter 11.3Chapter 11.3
Chapter 11.3
sotlsoc
 
Chapter 11.0
Chapter 11.0Chapter 11.0
Chapter 11.0
sotlsoc
 
Chapter 10.2
Chapter 10.2Chapter 10.2
Chapter 10.2
sotlsoc
 
Chapter 10.0
Chapter 10.0Chapter 10.0
Chapter 10.0
sotlsoc
 
Chapter 9.3
Chapter 9.3Chapter 9.3
Chapter 9.3
sotlsoc
 
Chapter 8.1
Chapter 8.1Chapter 8.1
Chapter 8.1
sotlsoc
 
Chapter 8.3
Chapter 8.3Chapter 8.3
Chapter 8.3
sotlsoc
 
Chapter 5.2
Chapter 5.2Chapter 5.2
Chapter 5.2
sotlsoc
 
Chapter 7.3
Chapter 7.3Chapter 7.3
Chapter 7.3
sotlsoc
 
Chapter 7.2
Chapter 7.2Chapter 7.2
Chapter 7.2
sotlsoc
 
Chapter 7.1
Chapter 7.1Chapter 7.1
Chapter 7.1
sotlsoc
 
Chapter 7.0
Chapter 7.0 Chapter 7.0
Chapter 7.0
sotlsoc
 
Chapter 6.6
Chapter 6.6Chapter 6.6
Chapter 6.6
sotlsoc
 
Chapter 6.5
Chapter 6.5Chapter 6.5
Chapter 6.5
sotlsoc
 

Más de sotlsoc (18)

Chapter 2.0 new
Chapter 2.0 newChapter 2.0 new
Chapter 2.0 new
 
Chapter 3.0 new
Chapter 3.0 newChapter 3.0 new
Chapter 3.0 new
 
Chapter 6.5 new
Chapter 6.5 newChapter 6.5 new
Chapter 6.5 new
 
Chapter 11.1
Chapter 11.1Chapter 11.1
Chapter 11.1
 
Chapter 11.3
Chapter 11.3Chapter 11.3
Chapter 11.3
 
Chapter 11.0
Chapter 11.0Chapter 11.0
Chapter 11.0
 
Chapter 10.2
Chapter 10.2Chapter 10.2
Chapter 10.2
 
Chapter 10.0
Chapter 10.0Chapter 10.0
Chapter 10.0
 
Chapter 9.3
Chapter 9.3Chapter 9.3
Chapter 9.3
 
Chapter 8.1
Chapter 8.1Chapter 8.1
Chapter 8.1
 
Chapter 8.3
Chapter 8.3Chapter 8.3
Chapter 8.3
 
Chapter 5.2
Chapter 5.2Chapter 5.2
Chapter 5.2
 
Chapter 7.3
Chapter 7.3Chapter 7.3
Chapter 7.3
 
Chapter 7.2
Chapter 7.2Chapter 7.2
Chapter 7.2
 
Chapter 7.1
Chapter 7.1Chapter 7.1
Chapter 7.1
 
Chapter 7.0
Chapter 7.0 Chapter 7.0
Chapter 7.0
 
Chapter 6.6
Chapter 6.6Chapter 6.6
Chapter 6.6
 
Chapter 6.5
Chapter 6.5Chapter 6.5
Chapter 6.5
 

Último

Último (20)

On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 

Chapter 9.4

  • 2. Objectives  After you have read and studied this chapter, you should be able to  Improve the reliability of code by incorporating exception-handling.  Implement the try-catch blocks for catching and handling exceptions.  Write methods that propagate exceptions.  Distinguish the checked and unchecked, or runtime, exceptions.
  • 3. Checked vs. Unchecked Exception  There are two types of exceptions:  Checked.  Unchecked.  A checked exception is an exception that is checked at compile time, so it must be handled.  An unchecked exception is not checked at compile time, so no need to handle (optional).  unchecked exception include Error and RuntimeException and their subclasses.  checked exception include Exception and its subclasses.
  • 4. Different Handling Rules  When calling a method that can throw checked exceptions  use the try-catch statement and place the call in the try block, or  modify the method header to include the appropriate throws clause.  When calling a method that can throw runtime exceptions, it is optional to use the try-catch statement or modify the method header to include a throws clause.