-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexception3.java
More file actions
32 lines (25 loc) · 827 Bytes
/
exception3.java
File metadata and controls
32 lines (25 loc) · 827 Bytes
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
import java.util.Scanner;
public class exception3{
public static void main(final String[] args) {
int a, b, c;
final Scanner sc = new Scanner(System.in);
System.out.println("enter the value of a = ");
a = sc.nextInt();
System.out.println("enter the value of b = ");
b = sc.nextInt();
try {
c = a / (a - b);
System.out.println("the value of c = " + c);
} catch (final ArithmeticException ae) {
System.out.println("division by zero");
}
catch (final ArrayIndexOutOfBoundsException aie)
{
System.out.println("array index out of bond exception occures");
}
finally
{
System.out.println("I am in final block ");
}
}
}