-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchecked_unchecked.java
More file actions
55 lines (30 loc) · 847 Bytes
/
checked_unchecked.java
File metadata and controls
55 lines (30 loc) · 847 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package class_programs;
import java.io.*;
class exception {
void unchecked() {
int[] a= {3,2,4,2,1};
try {
System.out.println(a[9]);
}
catch(ArrayIndexOutOfBoundsException e) {
System.out.println("Array out of bound exception was thrown inside unchecked method");
}
}
void checked() {
FileInputStream file;
try {
file = new FileInputStream("c:/desktop/java/no_file.txt");
}
catch(FileNotFoundException e) {
System.out.println("File is not found in the system. Exception thrown inside checked method");
}
}
}
public class checked_unchecked {
public static void main(String[] args) {
System.out.println("This program is written by Ashik MR, 4NI19IS017, B section");
exception obj=new exception();
obj.unchecked();
obj.checked();
}
}