Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute CPA-21-02 Exam - Topic 7 Question 56 Discussion

Posted by Lindsey on Jun 23, 2026 at 12:39 AM

What is the output of the program?

#include

#include

using namespace std;

int main () {

string s1 = "Hello", s2 = "World";

s2 = s1 + s2;

cout << s2;

return 0;

}

Suggested Answer: B

Get Premium CPA-21-02 Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
15 comments · newest first
FR
Francesco 1 month ago
So, B is the correct answer, right?
PE
Pedro 1 month ago
Exactly! "Hello" comes first.
CA
Carole 2 months ago
The output combines both strings.
FR
Francesco 2 months ago
I feel confused, but I agree with Carole.
PE
Pedro 2 months ago
Yeah, because s2 is assigned s1 + s2.
CA
Carole 2 months ago
I think it prints: HelloWorld.
SH
Sheridan 2 months ago
Just a simple string concatenation, nothing surprising here.
HI
Hillary 2 months ago
That's interesting, I didn't expect that output!
MY
My 3 months ago
Wait, are you sure? I thought it would be option C.
DU
Dustin 3 months ago
Totally agree, option B is correct!
GA
Gary 3 months ago
It prints: HelloWorld
MI
Mitzie 3 months ago
I practiced a question like this before, and I believe it concatenates the strings in the order they are written, so it should be "HelloWorld".
CA
Cassie 3 months ago
I feel like it could be "WorldHello" because s2 was originally "World" and then modified, but I’m confused about the order.
JA
Jame 3 months ago
I'm not entirely sure, but I remember something similar where string concatenation was involved. I think it might be option B.
ST
Stanford 4 months ago
I think the output will be "HelloWorld" since s2 is assigned the value of s1 + s2.
0/2000 characters

Save Cancel