Question Detail
Question
Given the code:
What will be the final value of
name = 'John'greeting = 'Hello, ' + name + '!'What will be the final value of
greeting?
Correct Answer
Option A is the correct answer.
Detailed Explanation
The concatenation starts with 'Hello, '. Then 'John' is added. Finally, '!' is added. The space after the comma is part of 'Hello, ', and there is no space after 'John' or before '!'. So, 'Hello, ' + 'John' + '!' results in 'Hello, John!'.
Hint
Trace the concatenation step-by-step and observe where spaces are explicitly included in the string literals.