Experiment 12
Experiment 12
2024-25
Code:
import java.io.*;
main(String[] args) {
try {
Class.forName("com.example.NonExistentClass");
} catch (ClassNotFoundException e) {
try {
} catch (IOException e) {
try {
num = Integer.parseInt(invalidNumber); }
catch (NumberFormatException e) {
} try {
int result = 10 / 0;
} catch (ArithmeticException e) {
} try { int[]
= arr[5];
Object Oriented Programming using Java Laboratory (DJS23FLES201) Academic Year
2024-25
} catch (ArrayIndexOutOfBoundsException e) {
} catch (NullPointerException e) {
}
}
Output:
Code:
import java.io.*;
}
}
Object Oriented Programming using Java Laboratory (DJS23FLES201) Academic Year
2024-25
} catch (IOException e) {
System.out.println("IO Error: " + e);
} catch (NumberFormatException e) {
System.out.println("Invalid number format.");
} catch (MarksOutOfBoundsException e) {
System.out.println("Custom Exception Caught: " + e.getMessage());
}
}
}
Output: