What will be printed out as the result of the following code execution?

public class Exceptions {
    public static void main(String[] args) {
        try {
            throw new UnsupportedOperationException();
        } catch(Throwable t) {
            System.out.print("1");
        } catch(Exception e) {
            System.out.print("2");
        } catch(UnsupportedOperationException uoe) {
            System.out.print("3");
        }
    }
}
Explanation
Code will not compile. All exceptions in java are inherited from Throwable. In a few catch blocks exception handling has to go up the hierarchy of exceptions (in this case from the most specific - UnsupportedOperationException to more general - Throwable, but not vice versa).

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з Java
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести