A

Admin • 828.03K Points
Coach

Q. What is the output of the following code snippet?

Code:
String s1 = ” Hello “;
System.out.println(sA)trim());
  • (A) Hello
  • (B) (space)Hello(space)
  • (C) Error
  • (D) None of the above
  • Correct Answer - Option(A)
  • Views: 12
  • Filed under category Java
  • Hashtags:

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

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.