SlideShare uma empresa Scribd logo
1 de 15
EXCEPTIONS IN JAVA
Sameer Patil
patilfriends@gmail.com
CONCEPTS OF EXCEPTION
 An Exception is runtime error that occur during the
execution of java program.
 Error Handling becomes a necessity when develop
applications that need to take care of unexpected
situations.
 If u divide by zero or open the file that doesn’t exist,
an exception is raised..
 Exception can be handle by run time system or
user defined code.
EXCEPTION CLASSES
 In Java run time systems searches for an exception
Handler.
 In java , a catch statements is an exception handler
is used to handle exceptions.
 The search for an exception handler begins with the
method in which exception is raised.
 If no appropriate exception handler is found, the
java run-time system searches the exception
Handler in next method hierarchy .
 The type of Exception handled by exception
handler should match the type of exception
thrown.
 The java runtime system proceeds with normal
execution of the program after an exception get
handled.
 If no appropriate exception-handler is found by the
java run time system, the program is terminated.
 In java Throwable class is the superclass of
exception classes.
 Object class is the base class of exception
hierarchy .
 The Exception class and the Error class are the two
subclasses of Throwable classes.`
OBJECT IS BASE CLAS
Throwable
Exception
ClassNotFoundException
InturruptedException
Error ThreadDeath
Throwable
IllegalAccess Exception
RuntimeException
IllegalArgument Exception
IndexOutOfBoundExeption
NullPointerExcception
RuntimeException
IndexOutofBoundException
ArrayIndexOutOfBoundException
StringIndexOutOf BoundExeption
IllegalArgumentException NumberFormatException
THROWABLE CLASS
 Throwable class is subclass of the object class.
 Throwable class is the superclass of all the
exception objects that are derived from throwable
class
 We can create constructor of Throwable class
 Throwable( ) or Throwable(String Message)
EXCEPTION CLASS
 The Exception class has various subclasses, such
as
 ClassNotFoundException,
 IllegalAcessException
 and RuntimeException.
 When this above exception will fire?
ERROR CLASS
 Error class define exception related to the java run
time environment.
 For example, OutOfMemoryError is an error that
occur when there is insufficient system memory to
execute the program.
 A program is abruptly aborted when an error object
is thrown.
 Error class throw two constructor.
BUILT IN EXCEPTIONS
 Checked Exception
 Unchecked Exception
 Checked Exception are the objects of the Exception
class or any of its subclasses excluding Runtime
Exception classes.
 Checked Exception are the invalid condition that
occur in java program due to invalid user input,
network connectivity problem or database problem.
 For ex:java.io.IOException is checked exception.
 The IOException is thrown whenever i/o operations
is abnormally terminated
Exception Cause of Creation
ClassNotFoundException Occurs when the Java run-time
system is unable to find the class
referred
IllegalAccessException Occurs when you want to refer a
class that is not accessible
InstantiationException Occurs when you try to create an
object of an abstract class or
interface
NoSuchMethodException Occurs when you call a method
that does not exist
UNCHECKED EXCEPTION
 Are the runtime errors that occur because of
programing errors, such as invalid argument
passed to a public method.
 The Java compiler does not check the unchecked
exception during program compilation.
 For example if you divide a number by zero, a
unchecked or runtime exception is raised
Exception Cause of Creation
ArithmeticException Occurs when you make an
arithmetic error, such as dividing a
number by zero
ArrayIndexOutOfBoundsException Occurs when an attempt is made
to access an array elements
beyond the index of the array.
ArrayStoreException Occurs when you assign an
elements to an array that is not
compatible with the data types of
that array
ClassCastException Occurs when you assign a
reference variable of a class to
an incompatible reference variable
of another class
IllegalArgumentException Occurs when you pass an
arguments of incompatible data
types to a method
NegativeArraySizeException Occurs when you create an array
with negative size
THANK YOU

Mais conteúdo relacionado

Mais procurados

Types of exceptions
Types of exceptionsTypes of exceptions
Types of exceptions
myrajendra
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
BHUVIJAYAVELU
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
priyankazope
 
Multi catch statement
Multi catch statementMulti catch statement
Multi catch statement
myrajendra
 
Exception handling in Java
Exception handling in JavaException handling in Java
Exception handling in Java
Prasad Sawant
 

Mais procurados (20)

Exception handling
Exception handling Exception handling
Exception handling
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Exception
ExceptionException
Exception
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
Types of exceptions
Types of exceptionsTypes of exceptions
Types of exceptions
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 
Exception handling
Exception handlingException handling
Exception handling
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 
Java Exception Handling and Applets
Java Exception Handling and AppletsJava Exception Handling and Applets
Java Exception Handling and Applets
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
exception handling
exception handlingexception handling
exception handling
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
Multi catch statement
Multi catch statementMulti catch statement
Multi catch statement
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Exception handling in Java
Exception handling in JavaException handling in Java
Exception handling in Java
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
Java: Exception
Java: ExceptionJava: Exception
Java: Exception
 
Exception Handling Java
Exception Handling JavaException Handling Java
Exception Handling Java
 
Creating your own exception
Creating your own exceptionCreating your own exception
Creating your own exception
 
L14 exception handling
L14 exception handlingL14 exception handling
L14 exception handling
 

Destaque

Amish and health issues a
Amish and health issues aAmish and health issues a
Amish and health issues a
sharonbella
 
ข้อสอบ o-net ปี 54 คณิต
ข้อสอบ o-net ปี 54 คณิตข้อสอบ o-net ปี 54 คณิต
ข้อสอบ o-net ปี 54 คณิต
Ksm' Oom
 
τι υπάρχει πίσω από την κουρτίνα;
τι υπάρχει πίσω από την κουρτίνα;τι υπάρχει πίσω από την κουρτίνα;
τι υπάρχει πίσω από την κουρτίνα;
jpapoglou
 
ποιος είναι ο θείος πέτρος;
ποιος είναι ο θείος πέτρος;ποιος είναι ο θείος πέτρος;
ποιος είναι ο θείος πέτρος;
jpapoglou
 
Weather & climate journal
Weather & climate journalWeather & climate journal
Weather & climate journal
shknecht
 
โครงงานคอมพิวเตอร์
โครงงานคอมพิวเตอร์โครงงานคอมพิวเตอร์
โครงงานคอมพิวเตอร์
Ksm' Oom
 
Nebhe nov 19 2012 webinar
Nebhe nov 19 2012 webinarNebhe nov 19 2012 webinar
Nebhe nov 19 2012 webinar
MChan_NEBHE
 
เธ‡เธฒเธ™เธ„เธญเธก (1)
เธ‡เธฒเธ™เธ„เธญเธก (1)เธ‡เธฒเธ™เธ„เธญเธก (1)
เธ‡เธฒเธ™เธ„เธญเธก (1)
Noot Ting Tong
 
Head tutor training presentation
Head tutor training presentationHead tutor training presentation
Head tutor training presentation
britk89
 
Airu nebhe webinar 8 16-2012 final
Airu nebhe webinar 8 16-2012 finalAiru nebhe webinar 8 16-2012 final
Airu nebhe webinar 8 16-2012 final
MChan_NEBHE
 
CSR Public Value and the Business of Politics
CSR Public Value and the Business of PoliticsCSR Public Value and the Business of Politics
CSR Public Value and the Business of Politics
Dr. Miya Burt-Stewart
 

Destaque (20)

finanzas
finanzasfinanzas
finanzas
 
Amish and health issues a
Amish and health issues aAmish and health issues a
Amish and health issues a
 
Ecommerce
EcommerceEcommerce
Ecommerce
 
ข้อสอบ o-net ปี 54 คณิต
ข้อสอบ o-net ปี 54 คณิตข้อสอบ o-net ปี 54 คณิต
ข้อสอบ o-net ปี 54 คณิต
 
τι υπάρχει πίσω από την κουρτίνα;
τι υπάρχει πίσω από την κουρτίνα;τι υπάρχει πίσω από την κουρτίνα;
τι υπάρχει πίσω από την κουρτίνα;
 
Pat3
Pat3Pat3
Pat3
 
Supertech eco village noida extension @ 9953518822,9718337727 supertech eco v...
Supertech eco village noida extension @ 9953518822,9718337727 supertech eco v...Supertech eco village noida extension @ 9953518822,9718337727 supertech eco v...
Supertech eco village noida extension @ 9953518822,9718337727 supertech eco v...
 
ποιος είναι ο θείος πέτρος;
ποιος είναι ο θείος πέτρος;ποιος είναι ο θείος πέτρος;
ποιος είναι ο θείος πέτρος;
 
ปราสาทหินพิมาย
ปราสาทหินพิมายปราสาทหินพิมาย
ปราสาทหินพิมาย
 
Weather & climate journal
Weather & climate journalWeather & climate journal
Weather & climate journal
 
โครงงานคอมพิวเตอร์
โครงงานคอมพิวเตอร์โครงงานคอมพิวเตอร์
โครงงานคอมพิวเตอร์
 
Day1 woo
Day1 wooDay1 woo
Day1 woo
 
Universal Private Banking
Universal Private BankingUniversal Private Banking
Universal Private Banking
 
Nebhe nov 19 2012 webinar
Nebhe nov 19 2012 webinarNebhe nov 19 2012 webinar
Nebhe nov 19 2012 webinar
 
เธ‡เธฒเธ™เธ„เธญเธก (1)
เธ‡เธฒเธ™เธ„เธญเธก (1)เธ‡เธฒเธ™เธ„เธญเธก (1)
เธ‡เธฒเธ™เธ„เธญเธก (1)
 
SMC marketing Programs
SMC marketing ProgramsSMC marketing Programs
SMC marketing Programs
 
Head tutor training presentation
Head tutor training presentationHead tutor training presentation
Head tutor training presentation
 
Airu nebhe webinar 8 16-2012 final
Airu nebhe webinar 8 16-2012 finalAiru nebhe webinar 8 16-2012 final
Airu nebhe webinar 8 16-2012 final
 
CSR Public Value and the Business of Politics
CSR Public Value and the Business of PoliticsCSR Public Value and the Business of Politics
CSR Public Value and the Business of Politics
 
ใบงาน7
ใบงาน7ใบงาน7
ใบงาน7
 

Semelhante a Exceptions in java

9781111530532 ppt ch11
9781111530532 ppt ch119781111530532 ppt ch11
9781111530532 ppt ch11
Terry Yoast
 
9781439035665 ppt ch11
9781439035665 ppt ch119781439035665 ppt ch11
9781439035665 ppt ch11
Terry Yoast
 
Md07 exceptions&assertion
Md07 exceptions&assertionMd07 exceptions&assertion
Md07 exceptions&assertion
Rakesh Madugula
 
Java programming-Event Handling
Java programming-Event HandlingJava programming-Event Handling
Java programming-Event Handling
Java Programming
 

Semelhante a Exceptions in java (20)

Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Java unit 11
Java unit 11Java unit 11
Java unit 11
 
Java Exceptions
Java ExceptionsJava Exceptions
Java Exceptions
 
Java Exceptions Handling
Java Exceptions Handling Java Exceptions Handling
Java Exceptions Handling
 
EXCEPTION HANDLING in prograaming
EXCEPTION HANDLING in prograamingEXCEPTION HANDLING in prograaming
EXCEPTION HANDLING in prograaming
 
Exception handling in Java
Exception handling in JavaException handling in Java
Exception handling in Java
 
9781111530532 ppt ch11
9781111530532 ppt ch119781111530532 ppt ch11
9781111530532 ppt ch11
 
Interface andexceptions
Interface andexceptionsInterface andexceptions
Interface andexceptions
 
Exceptions overview
Exceptions overviewExceptions overview
Exceptions overview
 
Java -Exception handlingunit-iv
Java -Exception handlingunit-ivJava -Exception handlingunit-iv
Java -Exception handlingunit-iv
 
Event handling
Event handlingEvent handling
Event handling
 
What is an exception in java?
What is an exception in java?What is an exception in java?
What is an exception in java?
 
OCA Java SE 8 Exam Chapter 6 Exceptions
OCA Java SE 8 Exam Chapter 6 ExceptionsOCA Java SE 8 Exam Chapter 6 Exceptions
OCA Java SE 8 Exam Chapter 6 Exceptions
 
9781439035665 ppt ch11
9781439035665 ppt ch119781439035665 ppt ch11
9781439035665 ppt ch11
 
Chap12
Chap12Chap12
Chap12
 
UNIT 2.pptx
UNIT 2.pptxUNIT 2.pptx
UNIT 2.pptx
 
Exception Handling.pptx
Exception Handling.pptxException Handling.pptx
Exception Handling.pptx
 
Md07 exceptions&assertion
Md07 exceptions&assertionMd07 exceptions&assertion
Md07 exceptions&assertion
 
Java programming-Event Handling
Java programming-Event HandlingJava programming-Event Handling
Java programming-Event Handling
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 

Último

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Último (20)

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
 
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
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
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)
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
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
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 

Exceptions in java

  • 1. EXCEPTIONS IN JAVA Sameer Patil patilfriends@gmail.com
  • 2. CONCEPTS OF EXCEPTION  An Exception is runtime error that occur during the execution of java program.  Error Handling becomes a necessity when develop applications that need to take care of unexpected situations.  If u divide by zero or open the file that doesn’t exist, an exception is raised..  Exception can be handle by run time system or user defined code.
  • 3. EXCEPTION CLASSES  In Java run time systems searches for an exception Handler.  In java , a catch statements is an exception handler is used to handle exceptions.  The search for an exception handler begins with the method in which exception is raised.  If no appropriate exception handler is found, the java run-time system searches the exception Handler in next method hierarchy .  The type of Exception handled by exception handler should match the type of exception thrown.
  • 4.  The java runtime system proceeds with normal execution of the program after an exception get handled.  If no appropriate exception-handler is found by the java run time system, the program is terminated.  In java Throwable class is the superclass of exception classes.  Object class is the base class of exception hierarchy .  The Exception class and the Error class are the two subclasses of Throwable classes.`
  • 5. OBJECT IS BASE CLAS Throwable Exception ClassNotFoundException InturruptedException Error ThreadDeath
  • 8. THROWABLE CLASS  Throwable class is subclass of the object class.  Throwable class is the superclass of all the exception objects that are derived from throwable class  We can create constructor of Throwable class  Throwable( ) or Throwable(String Message)
  • 9. EXCEPTION CLASS  The Exception class has various subclasses, such as  ClassNotFoundException,  IllegalAcessException  and RuntimeException.  When this above exception will fire?
  • 10. ERROR CLASS  Error class define exception related to the java run time environment.  For example, OutOfMemoryError is an error that occur when there is insufficient system memory to execute the program.  A program is abruptly aborted when an error object is thrown.  Error class throw two constructor.
  • 11. BUILT IN EXCEPTIONS  Checked Exception  Unchecked Exception  Checked Exception are the objects of the Exception class or any of its subclasses excluding Runtime Exception classes.  Checked Exception are the invalid condition that occur in java program due to invalid user input, network connectivity problem or database problem.  For ex:java.io.IOException is checked exception.  The IOException is thrown whenever i/o operations is abnormally terminated
  • 12. Exception Cause of Creation ClassNotFoundException Occurs when the Java run-time system is unable to find the class referred IllegalAccessException Occurs when you want to refer a class that is not accessible InstantiationException Occurs when you try to create an object of an abstract class or interface NoSuchMethodException Occurs when you call a method that does not exist
  • 13. UNCHECKED EXCEPTION  Are the runtime errors that occur because of programing errors, such as invalid argument passed to a public method.  The Java compiler does not check the unchecked exception during program compilation.  For example if you divide a number by zero, a unchecked or runtime exception is raised
  • 14. Exception Cause of Creation ArithmeticException Occurs when you make an arithmetic error, such as dividing a number by zero ArrayIndexOutOfBoundsException Occurs when an attempt is made to access an array elements beyond the index of the array. ArrayStoreException Occurs when you assign an elements to an array that is not compatible with the data types of that array ClassCastException Occurs when you assign a reference variable of a class to an incompatible reference variable of another class IllegalArgumentException Occurs when you pass an arguments of incompatible data types to a method NegativeArraySizeException Occurs when you create an array with negative size