P

Pushkar • 380 Points
Valuable

Q. What is the output of the following code?

Code:
String name = “John”;
System.out.println(“Hello, ” + name + “!”);
  • (A) Hello, John!
  • (B) Hello, name!
  • (C) Hello, !
  • (D) John

Explanation by: Pushkar
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!”.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.