3.2k views
4 votes
str1=”Good” str2=”Evening” Does the concatenation of the above two strings give back a new string or does it concatenate on the string str1? How do you prove your point?

User Giulio
by
4.9k points

1 Answer

4 votes

Answer:

It gives a new string

Step-by-step explanation:

In programming; when two or more strings are concatenated by a concatenating operator, the result is always a new string.

From the question, we have that

str1 = "Good

str2 = "Evening"

Let's assume that + is the concatenating operator;

str1 + str2 = "Good" + "Evening" = "GoodEvening"

The result of concatenating str1 and str2 is a new string "GoodEvening" while str1 and str2 still maintain their original string value of "Good" and "Evening"

User Oksayt
by
4.6k points