Print 777.
a.replace("Hello!", "Welcome!") doesn’t change a. It creates a new string which is not used. Therefore, a.indexOf("Java") will return the same index (7) both times. The same index will be returned by b.indexOf("Java") since b is created from a.
Right one is D. As Tojose writes, Strings are immutable. When doing a.replace(), it returns a new string which in this case isnt saved anywhere, and so "a" remains the same.
the right answer id D. 777, because String is unmutable
upvoted 2 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
xplorerpj
7 months, 2 weeks agoUteman
8 months, 3 weeks agoc6437d5
10 months, 2 weeks agoBharadwaj240796
11 months, 4 weeks agotestostaws
1 year agosupersquax
1 year agomeltedolive
1 year agoTojose
1 year ago