Advertisements
Advertisements
Question
Given that:
String wt = "TELL ME WHEN WILL YOU COME?";
String wu = wt.replace('E', 'A');
How many replacements will take place?
Options
4
3
2
1
MCQ
Advertisements
Solution
4
Explanation:
- The
replace('E', 'A')method scans the entire string from left to right and substitutes every single occurrence of the character 'E' with the character 'A'. - By looking at the string
"T**E**LL M**E** WH**E**N WILL YOU COM**E**?", we can see that the letter 'E' appears exactly four times, meaning four individual character replacements will take place.
shaalaa.com
Is there an error in this question or solution?
Chapter 10: String Handling - Exercises [Page 245]
