Worksheet: String Functions

Consider the following – what is output?

String w1 = "The Adventure of the Tall Man";
String w2 = "The Hound of the Baskervilles";

1. System.out.println(w1.length()); //

2. System.out.println(w2.substring(4)); //

3. System.out.println(w1.substring (w1.length()- 4)); //

4. System.out.println(w1.indexOf('d')); //

5. System.out.println(w2.indexOf('d')); //

6. System.out.println(w1.compareTo(w2)); //

7. System.out.println(w2.charAt(w2.length()-1)); //

8. System.out.println(w2.charAt(4)); //

9. System.out.println(w1.charAt(w2.indexOf('B'))); //

10. System.out.println(w2.substring(w1.indexOf('d'))); //

11. System.out.println(w2.substring(17).toUpperCase());//

Answer these in OneNote in the Class Notes section
The remaining questions are in OneNote in the Class Notes section