Q. What is the output of the following code snippet?
Code:
String s1 = “Hello”; String s2 = “World”; System.out.println(sA)concat(s2));
β
Correct Answer: (A)
HelloWorld
Explanation: The concat method in Java concatenates two strings together, returning a new string that is the combination of the two. In this case, sA)concat(s2) returns “HelloWorld”.