Bird
0
0

What will be the output of this PowerShell code?

medium📝 Command Output Q4 of 15
PowerShell - String Operations
What will be the output of this PowerShell code?
$a = "Hello"
$b = "World"
$c = $a + ", " + $b + "!"
Write-Output $c
AHello + , + World + !
BHello, World!
CHello,World!
DHelloWorld!
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the concatenation expression

    $a + ", " + $b + "!" joins Hello, then comma and space, then World, then exclamation.
  2. Step 2: Understand Write-Output prints the combined string

    The output will be the combined string exactly as concatenated.
  3. Final Answer:

    Hello, World! -> Option B
  4. Quick Check:

    Concatenation result = Hello, World! [OK]
Quick Trick: Concatenate with + to build full sentences [OK]
Common Mistakes:
  • Missing spaces in concatenation
  • Expecting operators to print literally
  • Confusing output with variable names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes