Q. What is the output of the following code?
Code:String name = “John”; System.out.println(“Hello, ” + name + “!”);
β
Correct Answer: (A)
Hello, John!
Explanation: The string concatenation operator (+) combines the string “Hello, ” with the value of the name variable (which is “John”) and the string “!”, resulting in the output “Hello, John!”.