What happens if a try statement places catch (Exception e) before catch (IOException e)?
Correct answer C. The code fails to compile
Explanation
Catch clauses are tested in order, and a clause for Exception already covers every IOException, so the later clause could never run. The language makes this a compile-time error rather than a warning. Always list more specific exception types before their superclasses, so that each handler can be reached.
Answer checked How we write and check questions
Discussion