public class ExceptionTest {
    public static void errorHandling() {
        System.out.println("Error");
        throw new IllegalAccessException();
    }
    
    public static void main(String[] args) {
        try {
            errorHandling();
        } catch (IllegalAccessException e) {
            System.out.println("Main error");
        }
    }
}
What is the result of executing?
Explanation
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.
Java
Java Quiz
Start Quiz

or Read more about Java Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback