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.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes