Bird
0
0

Which block always runs regardless of whether an exception is thrown or not?

easy📝 Conceptual Q2 of 15
PHP - Error and Exception Handling

Which block always runs regardless of whether an exception is thrown or not?

A<code>try</code> block
B<code>finally</code> block
CNone of the above
D<code>catch</code> block
Step-by-Step Solution
Solution:
  1. Step 1: Identify the role of finally block

    The finally block is designed to run after try and catch, no matter what happens.
  2. Step 2: Confirm behavior with or without exceptions

    Whether an exception occurs or not, the finally block always executes.
  3. Final Answer:

    finally block always runs. -> Option B
  4. Quick Check:

    finally runs always [OK]
Quick Trick: finally block always executes after try-catch [OK]
Common Mistakes:
  • Thinking catch runs without exception
  • Assuming try block runs after exception
  • Ignoring finally block existence

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes