Click to reopen instructions.

This is a test of writing methods that compute using Strings (and a few booleans and numbers) with the methods covered in Unit 2 and the + operator. As is usually the case when writing methods, you should be on the lookout for opportunities to implement methods in terms of other methods you’ve already written, especially in the later problems.

The questions are roughly arranged from easier to harder and the later ones are worth more. So if you get stuck on an early question, probably best to move on and come back to it.

Quick reference

  • String s = "Foo";
  • s + s ⟹ "FooFoo"
  • s.substring(0, 1) ⟹ "F"
  • s.length() ⟹ 3
  • s.toUpperCase() ⟹ "FOO"
  • s.toLowerCase() ⟹ "foo"
  • s.indexOf("o") ⟹ 1

Pro tip: when you click one of the method buttons, the name of the method is copied to your clipboard so you can paste it into your code, saving typing and avoiding spelling errors. Finally, click the black triangle at the start of these instructions to collapse them and have more room to code.

Put definitions here.

Revisions:

Test results show up here.

Errors