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.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты