Complete the code to create a new string by adding " World" to the original string.
String greeting = "Hello"; String newGreeting = greeting[1]" World";
In Java, strings are concatenated using the + operator.
Complete the code to convert the string to uppercase.
String text = "hello"; String upperText = text.[1]();
toLowerCase() instead of toUpperCase().The toUpperCase() method returns a new string with all letters in uppercase.
Fix the error in the code to correctly replace "cat" with "dog" in the string.
String animal = "cat"; String newAnimal = animal.[1]("cat", "dog");
replaceWith().replaceAll() which expects regex, but replace() is simpler here.The replace() method replaces all occurrences of a character sequence with another.
Fill both blanks to create a new string with "Java" repeated 3 times.
String repeated = "Java".[1](3); String result = repeated.[2]();
concat(3) which is invalid.repeat() for repeating strings.The repeat(3) method repeats the string 3 times, and toString() returns the string itself.
Fill all three blanks to create a new string with the first 4 characters of "immutable" in uppercase.
String word = "immutable"; String part = word.[1](0, [2]); String result = part.[3]();
length() instead of the number 4.substring correctly.The substring(0, 4) extracts the first 4 characters, and toUpperCase() converts them to uppercase.
