Skip to content
Sign in
Software Engineering

Which catch block should be written first when handling multiple exceptions?

Tap an option to check the answer. You can also press A–D.

Show answer

Correct answer: C) Specific

Specific exceptions should be caught before general ones to avoid being overshadowed. Writing a general exception first can prevent specific exception blocks from executing.
Explanation
Specific exceptions should be caught before general ones to avoid being overshadowed. Writing a general exception first can prevent specific exception blocks from executing.