πŸ“Š JAVA
Q. What is the output of the following code snippet?
Code:
String s1 = “Hello”;
System.out.println(sA)replaceAll(“l”, “z”));
  • (A) Hezzo
  • (B) Hezzz
  • (C) Hello
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (A) Hezzo

Explanation: The replaceAll method in Java replaces all occurrences of a specified substring in a string with another substring. In this case, sA)replaceAll(“l”, “z”) returns “Hezzo”, which is the string “Hello” with all “l” characters replaced with “z”.

Explanation by: Kirti
The replaceAll method in Java replaces all occurrences of a specified substring in a string with another substring. In this case, sA)replaceAll(“l”, “z”) returns “Hezzo”, which is the string “Hello” with all “l” characters replaced with “z”.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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