1In java exception is an object. Exceptions are created when an abnormal
2situations are arised in our program. Exceptions can be created by JVM or
3by our application code. All Exception classes are defined in java.lang.
4In otherwords we can say Exception as run time error.
5
1An exception is an event, which occurs during the execution of a
2program, that disrupts the normal flow of the program's instructions.
1In java exception is an object. Exceptions are created when an abnormal
2situations are arised in our program. Exceptions can be created by JVM or
3by our application code. All Exception classes are defined in java.lang.
4In otherwords we can say Exception as run time error. I use try & catch blocks
5to handle any exceptions in my code.
6 I am familiar with major checked and unchecked exceptions and
7 handle it accordingly to make my code execution smooth
1
2public class Exception8 {
3public static void main(String[]args)
4{
5 fun1();
6 fun2();
7}
8static void fun1()
9{
10 fun3();
11}
12static void fun2()
13{
14 fun3();
15}
16static void fun3()
17{
18 try {
19 System.out.println(20/0);
20 }
21 catch(ArithmeticException e)
22 {
23 System.out.println("Zero divison ");
24 }
25}
26}
27
1We can handle exceptions in either of the two ways :
21) By specifying try catch block where we can catch the exception.
32) Declaring a method with throws clause