-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoop33.java
43 lines (32 loc) · 814 Bytes
/
oop33.java
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
42
43
class NegAr extends Exception{
public String toString(){
return "Exception";
}
}
public class oop33 {
public static int div(int a ,int b) throws ArithmeticException{
int c=a/b;
return c;
}
public static double area(int r )throws NegAr{
if(r<0){
throw new NegAr();
}
double a=Math.PI*r*r;
return a;
}
public static void main(String[] args) {
try {
int divide=div(3,2);
System.out.println(divide);
} catch (Exception e) {
System.out.println(e.toString());
}
try {
double arr=area(4);
System.out.println(arr);
} catch (Exception e) {
System.out.println(e.toString());
}
}
}