Exception Handling in Java - Java Exceptions - Javatpoint
Exception Handling in Java - Java Exceptions - Javatpoint
In this page, we will learn about Java exceptions, its type and the
difference between checked and unchecked exceptions.
https://www.javatpoint.com/exception-handling-in-java 1/12
4/26/2021 Exception Handling in Java | Java Exceptions - javatpoint
statement 1;
statement 2;
statement 3;
statement 4;
statement 6;
statement 7;
statement 8;
statement 9;
statement 10;
Do You Know?
https://www.javatpoint.com/exception-handling-in-java 2/12
4/26/2021 Exception Handling in Java | Java Exceptions - javatpoint
https://www.javatpoint.com/exception-handling-in-java 3/12
4/26/2021 Exception Handling in Java | Java Exceptions - javatpoint
1. Checked Exception
2. Unchecked Exception
3. Error
https://www.javatpoint.com/exception-handling-in-java 4/12
4/26/2021 Exception Handling in Java | Java Exceptions - javatpoint
2) Unchecked Exception
3) Error
Keyword Description
https://www.javatpoint.com/exception-handling-in-java 6/12
4/26/2021 Exception Handling in Java | Java Exceptions - javatpoint
try{
int data=100/0;
}catch(ArithmeticException e){System.out.println(e);}
Test it Now
Output:
int a=50/0;//ArithmeticException
https://www.javatpoint.com/exception-handling-in-java 7/12
4/26/2021 Exception Handling in Java | Java Exceptions - javatpoint
String s=null;
System.out.println(s.length());//NullPointerException
String s="abc";
int i=Integer.parseInt(s);//NumberFormatException
If you are inserting any value in the wrong index, it would result in
ArrayIndexOutOfBoundsException as shown below:
a[10]=50; //ArrayIndexOutOfBoundsException
https://www.javatpoint.com/exception-handling-in-java 8/12
4/26/2021 Exception Handling in Java | Java Exceptions - javatpoint
← Prev Next →
https://www.javatpoint.com/exception-handling-in-java 9/12
4/26/2021 Exception Handling in Java | Java Exceptions - javatpoint
Preparation
Interview Company
Questions Interview
Questions
Interview
Company
Trending Technologies
https://www.javatpoint.com/exception-handling-in-java 10/12
4/26/2021 Exception Handling in Java | Java Exceptions - javatpoint
B.Tech / MCA
DS
OS C. Network Compiler D.
https://www.javatpoint.com/exception-handling-in-java 11/12
4/26/2021 Exception Handling in Java | Java Exceptions - javatpoint
.Net
Data Mining
Tutorial
Data Mining
https://www.javatpoint.com/exception-handling-in-java 12/12