A

Admin • 828.43K Points
Coach

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
  • Correct Answer - Option(A)
  • Views: 21
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
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.

Be the first to start discuss.