logo Practice-It logo

BJP5 Self-Check 3.20: stringExpressions2

Language/Type: Java basics Strings
Author: Leslie Ferguson (on 2019/09/19)

Assuming that the following variables have been declared,

String str1 = "Q.E.D.";
String str2 = "Arcturan Megadonkey";
String str3 = "Sirius Cybernetics Corporation";

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

str1.length()
str2.length()
str1.toLowerCase()
str2.toUpperCase()
str1.substring(2, 4)
str2.substring(10, 14)
str1.indexOf("D")
str1.indexOf(".")
str2.indexOf("donkey")
str3.indexOf("X")
str2 + str3.charAt(17)
str3.substring(9, str3.indexOf("e"))
str3.substring(7, 12)
str2.toLowerCase().substring(9, 13) + str3.substring(18, str3.length() - 7)

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.