πŸ“Š JAVA
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
πŸ’¬ Discuss
βœ… 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”.

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

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
249
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Kirti
Publisher
πŸ“ˆ
96%
Success Rate