String str1 = "Kolkata".replace('k', 'a');
In the above statement, the effect on string Kolkata is
String str1 = "Kolkata".replace('k', 'a');String str1 = "Kolkata".replace('k', 'a');In the above statement, the effect on string Kolkata is Correct Answer All characters k are replaced by a.
replace() method returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.
Syntax: Here is the syntax of this method:
public String replace(char oldChar, char newChar)
Parameters: Here is the detail of the parameters:
oldChar -- the old character. newChar -- the new character.
Return Value: It returns a string derived from this string by replacing every occurrence of oldChar with newChar.
মোঃ আরিফুল ইসলাম
Feb 20, 2025