Q. What is the output of the following code snippet?
Code:
String s1 = “Hello”; System.out.println(sA)replaceAll(“l”, “z”));
β
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”.