SlideShare a Scribd company logo
EXCEPTION HANDLING
EXPLAINED BY HACKERS
PRESENTERS
• MUSKAN NAZEER
• AQSA ALTAF
• M. SHAHID
• M. WASEEM AKRAM
• M. AHMAD
• TALHA SHABBIR
AGENDA.
• What is Exception
• What is Exception Handling
• Exception Hierarchy in java
• Difference between Exception & Error.
• Types of Exception
• Types of Built-in- Exception
• Create and Handle Exception..
Exception
Exception Hierarchy
Exception Types.
Checked Exception
Unchecked Exception
Create & handle Exception
What is Exception
“An exception is an unexpected event, which occurs during the execution of a program i.e., at run
time, that disrupts the normal flow of the program.”
What is Exception handling:
“The Exception Handling in Java is one of the powerful mechanisms to handle the exception. in
program. so that the normal flow of the program can be maintained.”
Purpose:
The purpose of Exception handling is to detect and report an exception so that proper action can be
taken and prevent the program which is automatically terminate or stop the execution because of that
exception
Example:
Statement 1;
Statement 2;
Statement 3; (an exception occurs)
Statement 4;
Statement 5;
Suppose there are 5 Statements in a program and there occurs an exception at
Statement 3 the rest of the code of statement 3,4,5 will not be executed. If we
perform exception handling the rest of the statement will be executed.
If Exception occurs then we have two ways;
 pass the exception to its caller (using throws keyword)
 handle exception (using try, catch and finally keyword)
Keyword Used in Exception Handling are given:
Keywords Description
try
Java try block is used to enclose the code that might
throw an exception. The try block must be followed by
catch or finally.
catch
The "catch" block is used to handle the exception. It
must be followed by try block which means we can't
use catch block alone. catch block may be one or more
than one.
finally
The "finally" block is used to execute the necessary
code of the program. It is executed whether an
exception is handled or not.
Throws
The "throws" keyword is used to pass the exception to
its caller. It is always used with method signature.
Throw
“throw” keyword used to create user
define exception. it is used inside the method.
Exception Hierarchy in java
In the Java platform, many classes derive directly from Object, other classes derive from some of those
classes, and so on, forming a hierarchy of classes. Object is the parent class of all the classes in java.
Difference Between Exception and Error?
Exception Error
Exception occurs due to our Program. Error occurs due to lack of system resources.
Exception can be handled. Error cannot be handled.
Types:
Checked Exception
Unchecked Exception.
Type:
Unchecked Only.
Examples:
Null Pointer Exception, Array Index Out of Bounds
Exception, Class not Found Exception etc.
Examples:
Virtual Machine Error, Stack Over Flow Error,
Assertion Error, Linkage Error, Out of Memory Error,
etc..
Exception Types
Difference Between Built In exception and User Defined Exception?
Built In exception User Defined Exception
Built-in exceptions are the exceptions that are
already available in Java libraries.
Built-in exceptions are the exceptions that are not
available in Java libraries.
Predefined exceptions are raised implicitly
(Automatically) by the runtime system.
Predefined exception must be raised explicitly by
throw keyword.
Types:
Checked Exception
Unchecked exception
Types:
unchecked exception
Types of Built-in- Exception
 checked Exception:
 unchecked Exception.
Some exception are given:
 File Not Found Exception: This Exception is raised when a file is not accessible or does not exist.
 IO Exception: It is thrown when an input-output operation failed or interrupted
 NoSuchMethodException: It is thrown when accessing a method that is not found.
 Interrupted Exception: It is thrown when a thread is waiting, sleeping, or doing some processing, and it is
interrupted.
Checked Exception
“If compiler checks exception, then it is known as checked exception. These exceptions should be either
pass or handled during compile time. If we do not catch or handle them then the compiler will throw a
compilation error. These are the sub classes of the Exception class.”
FileNotFoundException:
Output:
Exception Handling
Output:
Unchecked Exception
If The compiler does not check exception it is known as unchecked exception. An unchecked exception (also
known as a runtime exception). Exceptions are checked at runtime.
Unchecked exceptions result from faulty logic that can occur anywhere in a software program. For example, if a
developer invokes a method on a null object, an unchecked NullPointerException occurs.
 Arithmetic Exception: It is thrown when an exceptional condition has occurred in an arithmetic operation.
 Array Index Out Of Bounds Exception: it occurs if we print out of bound array in program.
 Class Not Found Exception: it is occur if we delete the class of java file after comile.
 NoSuchMethodException: It is thrown when accessing a method that is not found.
 String Index out of Bounds Exception: It is thrown by String class methods to indicate that an index is either
negative or greater than the size of the string
Some exception are given:
ArithmeticException!
Handle Exception by Try Catch
Exception create ( by using throw keyword) Example
Output:
Exception Handling
output:
Execution
process
Catch block
Finally block
EXCEPTION HANDLING in prograaming

More Related Content

Similar to EXCEPTION HANDLING in prograaming

Exception handling
Exception handlingException handling
Exception handling
Karthik Sekar
 
Exception Handling.pptx
Exception Handling.pptxException Handling.pptx
Exception Handling.pptx
primevideos176
 
unit 4 msbte syallbus for sem 4 2024-2025
unit 4 msbte syallbus for sem 4 2024-2025unit 4 msbte syallbus for sem 4 2024-2025
unit 4 msbte syallbus for sem 4 2024-2025
AKSHAYBHABAD5
 
7.error management and exception handling
7.error management and exception handling7.error management and exception handling
7.error management and exception handlingDeepak Sharma
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
Itp 120 Chapt 18 2009 Exceptions & Assertions
Itp 120 Chapt 18 2009 Exceptions & AssertionsItp 120 Chapt 18 2009 Exceptions & Assertions
Itp 120 Chapt 18 2009 Exceptions & Assertionsphanleson
 
exception -ppt.pptx
exception -ppt.pptxexception -ppt.pptx
exception -ppt.pptx
DivyaKS18
 
Exception handling
Exception handlingException handling
Exception handling
pooja kumari
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
ravinderkaur165
 
Java exception
Java exception Java exception
Java exception
Arati Gadgil
 
Chap2 exception handling
Chap2 exception handlingChap2 exception handling
Chap2 exception handling
raksharao
 
Java-Unit 3- Chap2 exception handling
Java-Unit 3- Chap2 exception handlingJava-Unit 3- Chap2 exception handling
Java-Unit 3- Chap2 exception handling
raksharao
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
Kavitha713564
 
CS3391 -OOP -UNIT – III NOTES FINAL.pdf
CS3391 -OOP -UNIT – III  NOTES FINAL.pdfCS3391 -OOP -UNIT – III  NOTES FINAL.pdf
CS3391 -OOP -UNIT – III NOTES FINAL.pdf
AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING
 
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
Poornima E.G.
 
A36519192_21789_4_2018_Exception Handling.ppt
A36519192_21789_4_2018_Exception Handling.pptA36519192_21789_4_2018_Exception Handling.ppt
A36519192_21789_4_2018_Exception Handling.ppt
promila09
 
Exception handling
Exception handlingException handling
Exception handling
Raja Sekhar
 
Java unit 11
Java unit 11Java unit 11
Java unit 11
Shipra Swati
 
Java SE 11 Exception Handling
Java SE 11 Exception HandlingJava SE 11 Exception Handling
Java SE 11 Exception Handling
Ashwin Shiv
 

Similar to EXCEPTION HANDLING in prograaming (20)

Exception handling
Exception handlingException handling
Exception handling
 
Exception Handling.pptx
Exception Handling.pptxException Handling.pptx
Exception Handling.pptx
 
unit 4 msbte syallbus for sem 4 2024-2025
unit 4 msbte syallbus for sem 4 2024-2025unit 4 msbte syallbus for sem 4 2024-2025
unit 4 msbte syallbus for sem 4 2024-2025
 
7.error management and exception handling
7.error management and exception handling7.error management and exception handling
7.error management and exception handling
 
16 exception handling - i
16 exception handling - i16 exception handling - i
16 exception handling - i
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Itp 120 Chapt 18 2009 Exceptions & Assertions
Itp 120 Chapt 18 2009 Exceptions & AssertionsItp 120 Chapt 18 2009 Exceptions & Assertions
Itp 120 Chapt 18 2009 Exceptions & Assertions
 
exception -ppt.pptx
exception -ppt.pptxexception -ppt.pptx
exception -ppt.pptx
 
Exception handling
Exception handlingException handling
Exception handling
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Java exception
Java exception Java exception
Java exception
 
Chap2 exception handling
Chap2 exception handlingChap2 exception handling
Chap2 exception handling
 
Java-Unit 3- Chap2 exception handling
Java-Unit 3- Chap2 exception handlingJava-Unit 3- Chap2 exception handling
Java-Unit 3- Chap2 exception handling
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
CS3391 -OOP -UNIT – III NOTES FINAL.pdf
CS3391 -OOP -UNIT – III  NOTES FINAL.pdfCS3391 -OOP -UNIT – III  NOTES FINAL.pdf
CS3391 -OOP -UNIT – III NOTES FINAL.pdf
 
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
 
A36519192_21789_4_2018_Exception Handling.ppt
A36519192_21789_4_2018_Exception Handling.pptA36519192_21789_4_2018_Exception Handling.ppt
A36519192_21789_4_2018_Exception Handling.ppt
 
Exception handling
Exception handlingException handling
Exception handling
 
Java unit 11
Java unit 11Java unit 11
Java unit 11
 
Java SE 11 Exception Handling
Java SE 11 Exception HandlingJava SE 11 Exception Handling
Java SE 11 Exception Handling
 

Recently uploaded

Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Landownership in the Philippines under the Americans-2-pptx.pptx
Landownership in the Philippines under the Americans-2-pptx.pptxLandownership in the Philippines under the Americans-2-pptx.pptx
Landownership in the Philippines under the Americans-2-pptx.pptx
JezreelCabil2
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
NelTorrente
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 

Recently uploaded (20)

Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Landownership in the Philippines under the Americans-2-pptx.pptx
Landownership in the Philippines under the Americans-2-pptx.pptxLandownership in the Philippines under the Americans-2-pptx.pptx
Landownership in the Philippines under the Americans-2-pptx.pptx
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 

EXCEPTION HANDLING in prograaming

  • 2. PRESENTERS • MUSKAN NAZEER • AQSA ALTAF • M. SHAHID • M. WASEEM AKRAM • M. AHMAD • TALHA SHABBIR
  • 3. AGENDA. • What is Exception • What is Exception Handling • Exception Hierarchy in java • Difference between Exception & Error. • Types of Exception • Types of Built-in- Exception • Create and Handle Exception.. Exception Exception Hierarchy Exception Types. Checked Exception Unchecked Exception Create & handle Exception
  • 4. What is Exception “An exception is an unexpected event, which occurs during the execution of a program i.e., at run time, that disrupts the normal flow of the program.” What is Exception handling: “The Exception Handling in Java is one of the powerful mechanisms to handle the exception. in program. so that the normal flow of the program can be maintained.” Purpose: The purpose of Exception handling is to detect and report an exception so that proper action can be taken and prevent the program which is automatically terminate or stop the execution because of that exception
  • 5. Example: Statement 1; Statement 2; Statement 3; (an exception occurs) Statement 4; Statement 5; Suppose there are 5 Statements in a program and there occurs an exception at Statement 3 the rest of the code of statement 3,4,5 will not be executed. If we perform exception handling the rest of the statement will be executed. If Exception occurs then we have two ways;  pass the exception to its caller (using throws keyword)  handle exception (using try, catch and finally keyword)
  • 6. Keyword Used in Exception Handling are given: Keywords Description try Java try block is used to enclose the code that might throw an exception. The try block must be followed by catch or finally. catch The "catch" block is used to handle the exception. It must be followed by try block which means we can't use catch block alone. catch block may be one or more than one. finally The "finally" block is used to execute the necessary code of the program. It is executed whether an exception is handled or not. Throws The "throws" keyword is used to pass the exception to its caller. It is always used with method signature. Throw “throw” keyword used to create user define exception. it is used inside the method.
  • 7. Exception Hierarchy in java In the Java platform, many classes derive directly from Object, other classes derive from some of those classes, and so on, forming a hierarchy of classes. Object is the parent class of all the classes in java.
  • 8. Difference Between Exception and Error? Exception Error Exception occurs due to our Program. Error occurs due to lack of system resources. Exception can be handled. Error cannot be handled. Types: Checked Exception Unchecked Exception. Type: Unchecked Only. Examples: Null Pointer Exception, Array Index Out of Bounds Exception, Class not Found Exception etc. Examples: Virtual Machine Error, Stack Over Flow Error, Assertion Error, Linkage Error, Out of Memory Error, etc..
  • 10. Difference Between Built In exception and User Defined Exception? Built In exception User Defined Exception Built-in exceptions are the exceptions that are already available in Java libraries. Built-in exceptions are the exceptions that are not available in Java libraries. Predefined exceptions are raised implicitly (Automatically) by the runtime system. Predefined exception must be raised explicitly by throw keyword. Types: Checked Exception Unchecked exception Types: unchecked exception
  • 11. Types of Built-in- Exception  checked Exception:  unchecked Exception.
  • 12. Some exception are given:  File Not Found Exception: This Exception is raised when a file is not accessible or does not exist.  IO Exception: It is thrown when an input-output operation failed or interrupted  NoSuchMethodException: It is thrown when accessing a method that is not found.  Interrupted Exception: It is thrown when a thread is waiting, sleeping, or doing some processing, and it is interrupted. Checked Exception “If compiler checks exception, then it is known as checked exception. These exceptions should be either pass or handled during compile time. If we do not catch or handle them then the compiler will throw a compilation error. These are the sub classes of the Exception class.”
  • 15. Unchecked Exception If The compiler does not check exception it is known as unchecked exception. An unchecked exception (also known as a runtime exception). Exceptions are checked at runtime. Unchecked exceptions result from faulty logic that can occur anywhere in a software program. For example, if a developer invokes a method on a null object, an unchecked NullPointerException occurs.  Arithmetic Exception: It is thrown when an exceptional condition has occurred in an arithmetic operation.  Array Index Out Of Bounds Exception: it occurs if we print out of bound array in program.  Class Not Found Exception: it is occur if we delete the class of java file after comile.  NoSuchMethodException: It is thrown when accessing a method that is not found.  String Index out of Bounds Exception: It is thrown by String class methods to indicate that an index is either negative or greater than the size of the string Some exception are given:
  • 17. Handle Exception by Try Catch
  • 18.
  • 19. Exception create ( by using throw keyword) Example