Q. What is the output of the following code snippet?
Code:
String s1 = ” Hello “; System.out.println(sA)trim());
β
Correct Answer: (A)
Hello
Explanation: The trim method in Java returns a new string that is the original string with all leading and trailing whitespace removeD) In this case, sA)trim() returns “Hello”.