Q. What is the output of the following code?
Code:
String name = null; System.out.println(“Hello, ” + name + “!”);
β
Correct Answer: (B)
Hello, null!
Explanation: When a null reference is concatenated with a string, it is treated as the string “null”. So the output of this code is “Hello, null!”.