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

Code:
String s1 = “Hello”;
System.out.println(sA)endsWith(“lo”));
  • (A) True
  • (B) False
  • (C) Error
  • (D) None of these
πŸ’¬ Discuss
βœ… Correct Answer: (A) True
Explanation: The endsWith method in Java checks whether a string ends with a specified substring. In this case, sA)endsWith(“lo”) returns true because the string “Hello” ends with “lo”.
Explanation by: Kirti
The endsWith method in Java checks whether a string ends with a specified substring. In this case, sA)endsWith(“lo”) returns true because the string “Hello” ends with “lo”.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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