PCEP-30-02 · Question #75
The + operator, when applied to strings, performs:
The correct answer is B. Concatenation. When the + operator is applied to strings, it performs concatenation - joining two or more strings end-to-end (e.g., "Hello" + " World" produces "Hello World"). Options A, C, and D (subtraction, multiplication, division) are arithmetic operations that apply to numbers, not…
Question
Options
- ASubtraction
- BConcatenation
- CMultiplication
- DDivision
How the community answered
(51 responses)- A2% (1)
- B76% (39)
- C8% (4)
- D14% (7)
Explanation
When the + operator is applied to strings, it performs concatenation - joining two or more strings end-to-end (e.g., "Hello" + " World" produces "Hello World"). Options A, C, and D (subtraction, multiplication, division) are arithmetic operations that apply to numbers, not strings; most languages will either throw an error or produce unexpected results if you attempt these on string types. Option B is correct because + is overloaded in most programming languages to serve dual purposes: arithmetic addition for numbers and concatenation for strings. A handy memory tip: think of concatenation like gluing strings together - the + sign is the "glue," and just as you'd add building blocks in sequence, strings are joined in the order they appear.
Community Discussion
No community discussion yet for this question.