logo Practice-It logo

BJP4 Self-Check 3.19: stringExpressions

Language/Type: Java String
Author: Marty Stepp (on 2016/09/08)

Assuming that the following variables have been declared,

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

Evaluate the following expressions. Make sure to give a value of the appropriate type (such as including quotes around a String or apostrophes around a char).

str1.length()
str1.charAt(7)
str2.charAt(0)
str1.indexOf("o")
str2.toUpperCase()
str1.toLowerCase().indexOf("B")
str1.substring(4)
str2.substring(3, 14)
str2.replace("a", "oo")
str2.replace("gray", "white")
"str1".replace("r", "range")

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.