-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiv.java
More file actions
36 lines (31 loc) · 1.09 KB
/
Div.java
File metadata and controls
36 lines (31 loc) · 1.09 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
import java.util.Scanner;
class Div
{
public static void main(String[] args) {
//
Scanner sc=new Scanner(System.in);
int result=0;
System.out.println("enter 2 values to divide ");
int num1=sc.nextInt();
int num2=sc.nextInt();
try{
result=num1/num2;//exception occur at this line
}
catch(ArithmeticException obj)
{
System.out.println("pls give number greater than zero");
}
System.out.println("if exception occur this will never executed");
System.out.println("if exception occur this will never executed");
System.out.println("if exception occur this will never executed");
System.out.println("if exception occur this will never executed");
System.out.println("if exception occur this will never executed");
System.out.println("the result is :"+result);
Div Divobj=new Div();
System.out.println(Divobj instanceof Div);//true
System.out.println(Divobj instanceof Object);
sc.close();
}
}
//try catch finally throw throws
//Object class is superclass of all the classes