Bird
0
0

Which of the following is the correct syntax to catch an exception in Java?

easy📝 Syntax Q12 of 15
Java - Exception Handling
Which of the following is the correct syntax to catch an exception in Java?
Atry { /* code */ } catch (e) { /* handle */ }
Btry { /* code */ } catch Exception e { /* handle */ }
Ctry { /* code */ } catch { /* handle */ }
Dtry { /* code */ } catch (Exception e) { /* handle */ }
Step-by-Step Solution
Solution:
  1. Step 1: Check catch syntax

    The catch block must specify the exception type in parentheses, like catch (Exception e).
  2. Step 2: Identify correct option

    try { /* code */ } catch (Exception e) { /* handle */ } correctly uses parentheses and exception type; others miss parentheses or type.
  3. Final Answer:

    try { /* code */ } catch (Exception e) { /* handle */ } -> Option D
  4. Quick Check:

    Correct catch syntax = A [OK]
Quick Trick: Catch must have parentheses with exception type [OK]
Common Mistakes:
  • Omitting parentheses in catch
  • Not specifying exception type
  • Using wrong catch syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes