Question: Assuming that the following variables have been declared: evaluate the following expressions: a. str1.length() b. str1.charAt(7) c. str2.charAt(0) d. str1.indexOf(o) e. str2.toUpperCase() f. str1.toLowerCase().indexOf(B) g.

Assuming that the following variables have been declared:

// index 0123456789012345 String stri =

evaluate the following expressions:

a. str1.length()

b. str1.charAt(7)

c. str2.charAt(0)

d. str1.indexOf("o")

e. str2.toUpperCase()

f. str1.toLowerCase().indexOf("B")

g. str1.substring(4)

h. str2.substring(3, 14)

i. str2.replace("a", "oo")

j. str2.replace("gray", "white")

k. "str1".replace("r", "range")

// index 0123456789012345 String stri = "Frodo Baggins"; String str2 "Gandalf the GRAY";

Step by Step Solution

3.41 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Results of String expressions ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!