Bird
0
0

Which of the following is the correct syntax to concatenate the strings stored in $str1 and $str2 with a space in between?

easy📝 Syntax Q3 of 15
PowerShell - String Operations
Which of the following is the correct syntax to concatenate the strings stored in $str1 and $str2 with a space in between?
A$str1 / ' ' / $str2
B$str1 -join ' ' -join $str2
C$str1 * ' ' * $str2
D$str1 + ' ' + $str2
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct operator for string concatenation

    The + operator joins strings; to add a space, include ' ' between them.
  2. Step 2: Construct the expression

    $str1 + ' ' + $str2 correctly concatenates with a space.
  3. Final Answer:

    $str1 + ' ' + $str2 -> Option D
  4. Quick Check:

    Concatenate with + and spaces as strings [OK]
Quick Trick: Use + with ' ' to add spaces between strings [OK]
Common Mistakes:
  • Using -join incorrectly for strings
  • Using arithmetic operators like * or /
  • Forgetting to add space as a string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes