Difficulty: Easy
Correct Answer: 1, 3, 4
Explanation:
Introduction / Context:
This question reviews fundamental properties of string
and StringBuilder
and the standard concatenation syntax in C#.
Given Data / Assumptions:
Concept / Approach:
In C#, strings are immutable, and the +
operator concatenates strings. StringBuilder
provides a mutable buffer for efficient concatenations or edits. The &
concatenation operator is a VB feature, not C#.
Step-by-Step Solution:
s3 = s1 + s2
→ Valid in C#.2) 'String is a primitive' → False; it is a reference type with special handling.3) StringBuilder-built strings are mutable → True (the builder is mutable; resulting ToString()
is immutable).4) Strings are immutable → True.5) s3 = s1 & s2
→ Not C# syntax; false.
Verification / Alternative check:
Creating a StringBuilder
and appending confirms mutability; attempting to modify an existing string
shows it produces a new instance.
Why Other Options Are Wrong:
Options including 2 or 5 assert incorrect claims about primitives or use non-C# operators.
Common Pitfalls:
Assuming VB operators apply in C#; forgetting the performance implications of repeated +
in loops.
Final Answer:
1, 3, 4
Discussion & Comments