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).

Follow CodeGalaxy

Mobile Beta

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