Bird
0
0

What will this PowerShell expression return?

medium📝 Command Output Q5 of 15
PowerShell - Operators
What will this PowerShell expression return?
($x = 3) -eq 3 -or ($y = 4) -eq 4
AFalse
BError
CTrue
DNull
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate each comparison

    ($x = 3) assigns 3 to $x, then '-eq 3' compares 3 to 3 (true). Similarly, ($y = 4) assigns 4 to $y, '-eq 4' is true.
  2. Step 2: Apply '-or' operator

    Since first condition is true, '-or' returns true immediately.
  3. Final Answer:

    True -> Option C
  4. Quick Check:

    '-or' true if any condition true [OK]
Quick Trick: '-or' returns true if any condition is true [OK]
Common Mistakes:
  • Confusing assignment '=' with comparison '-eq'
  • Expecting error from assignment inside expression
  • Thinking both conditions must be true

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes