Catch blocks in the wrong order
QuizMediumJava onlyAsked in: Accenture, Capgemini, Cognizant, Infosys, TCS
What happens with this code?
try {
Integer.parseInt("x");
} catch (Exception e) {
System.out.println("general");
} catch (NumberFormatException e) {
System.out.println("number");
}- It does not compile
- It prints general
- It prints number
- It prints both lines
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.