Bird
0
0

What will be the output of this PowerShell code?

medium📝 Command Output Q13 of 15
PowerShell - Control Flow
What will be the output of this PowerShell code?
switch (3) {
  1 { 'One' }
  2 { 'Two' }
  3 { 'Three' }
  default { 'Other' }
}
AThree
BTwo
COther
DOne
Step-by-Step Solution
Solution:
  1. Step 1: Identify the switch value

    The switch is checking the value 3.
  2. Step 2: Match the case

    Case 3 matches and outputs 'Three'. Default is ignored because a match was found.
  3. Final Answer:

    Three -> Option A
  4. Quick Check:

    Value 3 matches case 3 = D [OK]
Quick Trick: Match value to case; default runs only if no match [OK]
Common Mistakes:
  • Choosing default even when a case matches
  • Confusing case numbers
  • Ignoring case order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes