Important Notice:

Practice-It will be discontinued as of November 1st, 2024. After this date, the website will remain online for a transitional period, but login will be restricted to University of Washington NetID authentication. This marks the next phase towards the platform's full retirement. Thank you for your use and support of the application over the years.

If you are looking for an alternative, a similar tool, CodeStepByStep, was developed independently by the original author of Practice-It, and is available at codestepbystep.com**

logo Practice-It logo

BJP3 Self-Check 3.20: stringExpressions2

Language/Type: Java basics Strings
Author: Leslie Ferguson (on 2016/09/08)

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.