Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
31 Cards in this Set
- Front
- Back
Assume str1 is "Apples" and str2 is "apples". True or False: str1.equals("Apples") |
True |
|
Assume str1 is "Apples" and str2 is "apples". True or False: str1.equals(str2) |
False |
|
Correct format for compareTo() to find if str1 is less-than str2 |
str1.compareTo(str2) < 0 |
|
Indicate the result of comparing the first string with the second string. Possible answers: less-than, equal, greater-than "Apples", "Oranges" |
less-than 'A' is less-than 'O' |
|
Indicate the result of comparing the first string with the second string. Possible answers: less-than, equal, greater-than "merry", "Merry" |
greater-than The coded value for 'm' is greater-than the coded value for 'M' |
|
Correct format for compareTo() to find if str1 is greater-than str2 |
str1.compareTo(str2) > 0 |
|
Correct format for compareTo() to find if str1 is equal-to str2 |
str1.compareTo(str2) == 0 |
|
Given userText is "Think". What character is at index 1 of userText? |
h Index numbering starts with 0. T is at index 0, h is at index 1. |
|
Given userText is "Think" To what character does this evaluate: userText.charAt(3) |
n Indexes start with 0, so 3 corresponds to the 4th character (0, 1, 2, *3*). |
|
Given userText is "March 17, 2034". What does userText.length() return? |
14 Count every character including spaces. |
|
Given userText is "March 17, 2034". What does userText.isEmpty() return? |
false The string is not empty. Same as userText.length() == 0. |
|
Given userText is "March 17, 2034". What does userText.indexOf(',') return? |
8 ',' is the 9th character, so its index is 8. |
|
Given userText is "March 17, 2034". What is the index of the last character in userText? |
13 There are 14 characters, so the index of the last character is 13. |
|
Given userText is "March 17, 2034". What character does userText.charAt(userText.length() - 1) return? |
4 That's one way to get the last character. |
|
Given userText is "March 17, 2034". What does userText.substring(0, 3) return? |
Mar String starting with M and ending with r. Remember: [substring(startIndex, endIndex] Returns substring starting at startIndex and ending at endIndex - 1. The length of the substring is given by endIndex - startIndex. |
|
Given userText is "March 17, 2034". What does userText.substring(userText.length() - 4, userText.length()) return? |
2034 That form gets the last 4 characters. |
|
What is the correct notation for charAt()? |
someString.charAt(0) The "0" determines the character at a particular index of a string . |
|
What is the correct notation for length()? Given String userText userText = "Happy" |
userText.length() Returns 5 |
|
What is the correct notation for indexOf(item)? String userText = "Help me!" |
userText.indexOf('p') That returns 3 |
|
What is the correct notation for substring(startIndex, endIndex)? String userText = "http://google.com" |
userText.substring(13, 17) Returns ".com" |
|
Correct notation for concat(moreString)? String userText = "Hi" String newText = "Hi there" |
// userText is "Hi" userText = userText.concat(" friend"); // Now "Hi friend" newText = userText.concat(" there"); // newText is "Hi there" |
|
Correct notation for replace(findStr, replaceStr) and replace(findChar, replaceChar)? |
// userText is "Hello" userText = userText.replace('H', 'j'); // Now "jello" // userText is "You have many gifts" userText = userText.replace("many", "a plethora of"); // Now "You have a plethora of gifts" // userText is "Goodbye" newText = userText.replace("bye"," evening"); // newText is "Good evening" |
|
Correct notation for str1 + str2? |
// userText is "A B" myString = userText + " C D"; // myString is "A B C D" myString = myString + '!'; // myString now "A B C D!" |
|
What is str1 += str2? |
Shorthand for str1 = str1 + str2. // userText is "My name is " userText += "Tom"; // Now "My name is Tom" |
|
To what value does each evaluate? userStr is "Hey #1?". True or False? Character.isLetter('7') |
False '7' is not an alphabetic letter (a-z or A-Z.) |
|
To what value does each evaluate? userStr is "Hey #1?". True or False? Character.isLetter(userStr.charAt(0)) |
True 'H' is alphabetic. |
|
To what value does each evaluate? userStr is "Hey #1?". True or False? Character.isWhitespace(userStr.charAt(3)) |
True That character is a space ' ' between the y and #. |
|
To what value does each evaluate? userStr is "Hey #1?". True or False? Character.isDigit(userStr.charAt(6)) |
False That character is '?'. |
|
To what value does each evaluate? userStr is "Hey #1?". True or False? Character.toUpperCase(userStr.charAt(1)) returns 'E'. |
True 'e' becomes 'E'. |
|
To what value does each evaluate? userStr is "Hey #1?". True or False? Character.toLowerCase(userStr.charAt(2)) yields an error because 'y' is already lower case . |
False No error, just returns 'y'. |
|
To what value does each evaluate? userStr is "Hey #1?". True or False? Character.toLowerCase(userStr.charAt(6)) yields an error because '?' is not alphabetic. |
False No error, just returns '?'. |