Recall & Review
beginner
What does the
length() method do in a Java String?It returns the number of characters in the string, including spaces and special characters.
touch_appClick to reveal answer
beginner
How does the
toUpperCase() method affect a string?It creates a new string where all letters are converted to uppercase. The original string stays the same.
touch_appClick to reveal answer
intermediate
What is the purpose of the
substring(int beginIndex, int endIndex) method?It extracts a part of the string starting at
beginIndex and ending just before endIndex, returning that part as a new string.touch_appClick to reveal answer
beginner
Explain what
equals(String anotherString) does.It checks if two strings have exactly the same characters in the same order and returns
true if they do, otherwise false.touch_appClick to reveal answer
beginner
What does the
trim() method do to a string?It removes any whitespace at the start and end of the string but does not change spaces inside the string.
touch_appClick to reveal answer
Which method returns the number of characters in a Java string?
What does
toLowerCase() do to a string?How do you get a part of a string from index 2 to 5 (exclusive) in Java?
Which method compares two strings for exact equality?
What does the
trim() method remove from a string?Describe five common string methods in Java and what each one does.
Explain how you would extract a substring and compare two strings for equality in Java.
