Bird
0
0

What is the output of this PowerShell code?

medium📝 Command Output Q4 of 15
PowerShell - Operators
What is the output of this PowerShell code?
$num = 10
$result = $num -eq 10 ? 'Ten' : 'Not Ten'
Write-Output $result
ATrue
BNot Ten
CFalse
DTen
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate the condition $num -eq 10

    The variable $num is 10, so $num -eq 10 is true.
  2. Step 2: Apply ternary operator

    Since the condition is true, the ternary operator returns 'Ten'.
  3. Final Answer:

    Ten -> Option D
  4. Quick Check:

    Condition true returns first value = Ten [OK]
Quick Trick: True condition returns first value after ? [OK]
Common Mistakes:
  • Confusing -eq with -ne
  • Expecting boolean output instead of string
  • Mixing up true and false branches

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes