Bird
0
0

In PowerShell, which block is executed only if an error occurs inside the try block?

easy📝 Conceptual Q2 of 15
PowerShell - Error Handling
In PowerShell, which block is executed only if an error occurs inside the try block?
Afinally
Bcatch
Ctry
Dbegin
Step-by-Step Solution
Solution:
  1. Step 1: Identify the error handling blocks

    The catch block is specifically designed to run only when an error occurs in the try block.
  2. Step 2: Eliminate other blocks

    finally runs always, try runs first, and begin is unrelated to error handling.
  3. Final Answer:

    catch -> Option B
  4. Quick Check:

    catch block = runs on error [OK]
Quick Trick: catch runs only on errors inside try [OK]
Common Mistakes:
  • Confusing finally with catch
  • Thinking try runs only on error
  • Using unrelated blocks like begin

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes