1. Analyse the following code. An empty string has a length of _______.
2. What is the length of the String "Hello World!"?
3. The '+' operator can be used to concatenate strings as well as the _________ method.
4. What is the output of the following code? (note the indexOf method)
String varOne = "Hello World!";
System.out.println(varOne.indexOf('W'));
5. While using the charAt method, in a case where the index is negative or greater than stringname.length()-1, _____________________________.
6. Refer to the following code. What is printed when the statement exampleVariableOne.charAt(0); is called?
7. Refer to the code below. What does the statement: exampleVariableOne.substring(6) return?
8. Referring to the above code, fill in the blanks. Strings are ___________, so a new String is created every time you call either of the substring() methods.
9. The following code will print the string "Hello". True or False?
10. In the compareTo() method, if the first two letters of the strings are the same, the method will go on to compare the next letters, and the next until ____________.
11. The compareTo() method returns 1 if the two strings are equal, a number less than 10 if the first String is larger, and a number greater than -1 if the second String is larger.
12. When using the compareTo() method, uppercase letters come before lowercase letters when the method compares strings
13. When the following code is executed, '2' is printed.
14. After this code is executed, which of the following statements will evaluate to true?
15. The following code simply takes the string and _______________.
16. Analyse the following code. The parseInt() method returns an _____, not an object from the Integer class.
17. The parseInt() function has many uses but would NOT be useful when dealing with user input or calculating numbers from text files.
18. The following statement would be considered correct.
19. The toString() method takes ____________ in Java and converts it to a String.
20. Read the following and decide whether the output listed at the start is correct. Select 'True' if correct, and 'False' if incorrect.
21. What is the output of the following code?
22. The following code will produce the output: Return Value :MOOSE
23. The following code snippet compares strings to find out if they are equal, ignoring case differences.
24. Which of the following methods returns the index within this string of the first occurrence of the specified substring.
25. Analyse the following method (see code below). This essentially returns a copy of the string with __________________.