Advertisements
Advertisements
Question
Which of the following returns a String?
Options
length()
charAt(int)
replace(char, char)
indexOf(String)
MCQ
Solution
replace(char, char)
Explanation:
The method replace(char oldChar, char newChar) returns a new String with all occurrences of oldChar replaced by newChar. This method does not modify the original string but produces a new one with the specified replacements.
shaalaa.com
String Array
Is there an error in this question or solution?