← Quiz: Java Exception Handling: all 10 questions
Quiz: Java Exception Handling · Question 4 of 10
Which order of catch blocks compiles?
Which order of catch blocks compiles?
- A.catch (ArithmeticException e) then catch (Exception e)
- B.catch (Exception e) then catch (ArithmeticException e)
- C.Both orders compile
- D.Neither compiles
Answer & explanation
Correct answer: catch (ArithmeticException e) then catch (Exception e)
A general catch first would make the specific one unreachable, which is a compile error.
Can you get the rest right without peeking?
Take the timed Quiz: Java Exception Handling quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →