-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDivisionExceptionFinally.java
More file actions
41 lines (32 loc) · 1.01 KB
/
DivisionExceptionFinally.java
File metadata and controls
41 lines (32 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.util.*;
class DivisionExceptionFinally{
public static void main(String A[])
{
Scanner sobj = new Scanner(System.in);
int No1 = 0, No2 = 0, Ans = 0;
System.out.println("Enter first number : ");
No1 = sobj.nextInt();
System.out.println("Enter second number : ");
No2 = sobj.nextInt();
try
{
System.out.println("Inside try block");
Ans = No1 / No2 ;
}
catch(ArithmeticException aobj)
{
System.out.println("Inside catch block");
System.out.println("Exception occured : "+aobj);
}
catch(Exception eobj)
{
System.out.println("Inside generic catch : "+eobj);
}
finally{
System.out.println("Inside finally block");
sobj = null ; // Resource Deallocation
System.gc();
}
System.out.println("Division is : "+Ans);
}
}