Activity 2.2 - Experimenting with strings and concatenation

Topic

This activity gives you practise in the use of string concatenation and escape sequences.

Materials

In addition to the discussion of the solution in the Solution document, the project for this activity contains two classes:

Task

You are asked to build two strings which, when printed, will result in the following output:

Sherlock Holmes and Dr. Watson lived at No. 221B, Baker Street.
"ABC,
double-XYZ,"
she recited. 

Instructions

  1. Run the project. You should find that to start with it simply prints the message : End of output.
  2. Now open the class Ex2_2 and read the method output. Follow the instructions there.
  3. When you have made the required changes, run the project to test whether your solution is correct.
  4. You might want to do the activity in stages, testing your output as you go.