public class ExceptionTest {
    public static void errorHandling() {
        throw new IllegalAccessException();
    public static void main(String[] args) {
        try {
        } catch (IllegalAccessException e) {
            System.out.println("Main error");
What is the result of executing?
Compilation error will appear, because IllegalAccessException is a checked exception.
It means the method errorHandling must either contain throws declaration or handle the exception itself.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback