java chapter 14 self review and terms
______________ that takes a String object copies the argument into the new String.
Constructor
When string objects are compared using ==, the result is true if the Strings contains the same value.
False. String objects are compared using operator == to determine whether they're the same object in memory.
A String can be modified after it's created.
False. String objects are immutable and cannot be modified after they're created. StringBuilder can be modified after they're created.
predefined character classes that cannot be used with regular expressions.
False. predefined character classes that can be used with regular expressions.
Class ______________ is used to represent strings in Java
String
Method *equals* (a method of class Object overridden in String) tests any two objects for equality. The method returns true if the contents of the objects are equal, and false otherwise. Method equals uses a lexicographical comparison
String Method equals
________________ (stored in memory as String objects) are written as a sequence of characters in double quotation marks.
String literals
If multiple threads require access to the same dynamic string information, use class _________ in your code.
StringBuffer
Class __________________ is used to create and manipulate dynamic string information
StringBuilder
Every _______________ is capable of storing a number of characters specified by it's capacity.
StringBuilder
If a __________________ capacity is exceeded, the capacity expands to accommodate additional characters.
StringBuilder's
Specifying an index outside the bounds of the String causes a ______________________.
StringIndexOutOfBoundsException
Other characters can also be used as delimiters to separate tokens.
True
The value of a character literal is the integer value of the character in the ______________________.
Unicode character set
Overloaded ___________ methods allow values of various types to be appended to the end of a StringBuilder.
append
Java automatically converts ___________ literals into Character objects when they are assigned to Character variables
char
Method ____________ takes an integer argument and returns the character in the StringBuilder at that index.
charAt
String method ____________ returns the character at a specific position in the String.
charAt
Method ____________ returns the char value stored in the object.
charValue
A program may contain ________________
character literals
________________ is an integer value represented as a character in single quotes.
character literals
A String method that compares a specified String to the current String.
compareTo
Method _______________ is declared in the Comparable interface and implemented in the String class.
compareTo
String method ___________ concatenates two String objects (similar to using the + operator) and returns a new String object containing the characters from both original Strings.
concat
Constructor that takes a char array creates a String ____________________________________________.
containing a copy of the characters in the array.
Constructor that takes a char array and two integers creates a String ______________________________.
containing the specified portion of the array.
Constructor that takes a String argument
creates a StringBuilder containing the characters in the String argument. The initial capacity is the number of characters in the String argument plus 16.
No-argument constructor
creates a StringBuilder with no characters in it and an initial capacity of 16 characters.
Constructor that takes an integer argument
creates a StringBuilder with no characters in it and the initial capacity specified by the integer argument.
Method ___________ takes two arguments—the starting index and the index one past the end of the characters to delete.
delete
Methods ___________ and ________________ delete characters at any position in a StringBuilder.
delete, deleteCharAt
Method _____________________ takes one argument—the index of the character to delete.
deleteCharAt
Tokens are separated by _____________ Typically white-space characters such as space, tab, newline and carriage return.
delimiters
Character method ___________ converts its first argument into an integer in the number system specified by its second argument.
digit
Methods ___________ and ____________ convert characters to digits and digits to characters, respectively, in different number systems.
digit, forDigit
No-argument constructor creates a String that contains no characters (i.e., the ______________, which can also be represented as "") and has a length of 0.
empty string
Method ________________ guarantees that a StringBuilder has at least the specified capacity.
ensureCapacity
Method ______________ determines if two Characters have the same contents.
equals
String method __________________ ignores whether the letters in each String are uppercase or lowercase when performing the comparison.
equalsIgnoreCase
____________ performs a case-insensitive comparison. Thus, "hello" and "HELLO" compare as equal.
equalsIgnoreCase
Character method ___________converts its first argument into a character in the number system specified by its second argument.
forDigit
Method ____________ copies characters from a StringBuilder into the character array argument.
getChars
String method ___________ copies the characters of a String into a character array.
getChars
All of the quantifiers are _______________.
greedy
A second version of ____________ takes two integer arguments—the character and the starting index at which the search of the String should begin.
indexOf
Method ___________ locates the first occurrence of a character in a String. If the method finds the character, it returns the character's index in the String—otherwise, it returns -1.
indexOf
String methods ____________ and _______________ that search for a specified character or substring in a String.
indexOf, lastIndexOf
Overloaded _______________ methods insert values of various types at any position in a StringBuilder.
insert
Method ____________ determines whether a character is defined in the Unicode character set.
isDefined
Method ______________ determines whether a character is a defined Unicode digit.
isDigit
Method ___________________ determine whether a character can be used in an identifier in Java—that is, a digit, a letter, an underscore (_) or a dollar sign ($).
isJavaIdentifierPart
Method __________________ determines whether a character can be the first character of an identifier in Java—that is, a letter, an underscore (_) or a dollar sign ($).
isJavaIdentifierStart
Method ________________ determines whether a character is a letter.
isLetter
Method __________________ determines whether a character is a letter or a digit.
isLetterOrDigit
Method _______________ determines whether a character is a lowercase letter.
isLowerCase
Method ______________ determines whether a character is an uppercase letter.
isUpperCase
A second version of ______________ takes two integer arguments—the integer representation of the character and the index from which to begin searching backward. There are also versions of these methods that search for substrings in Strings.
lastIndexOf
Method _______________ locates the last occurrence of a character in a String. The method searches from the end of the String toward the beginning. If it finds the character, it returns the character's index in the String—otherwise, it returns -1.
lastIndexOf
String method ______________ determines the number of characters in a string
length
Methods ____________ and ____________ return the number of characters currently in a StringBuilder and the number of characters that can be stored in a without allocating more memory, respectively.
length, capacity
_______________ compares the integer Unicode values that represent each character in a string.
lexicographical comparison
when you use the compareTo method to compare two strings, the strings are compared character by character.
lexicographical comparison
String method ______________ receives a String that specifies the regular expression and matches the contents of the String object on which it's called to the regular expression.
matches
Strings are compared using the ___________ codes of the characters in the strings.
numeric
Java treats all string literal objects with the same contents as ________________ to which there can be many references.
one String object
When ________ values are compared with ==, the result is true if both values are identical
primitive-type
The asterisk (*) and plus (+) are formally called ___________.
quantifiers.
Common number systems: decimal (base 10), octal (base 8), hexadecimal (base 16) and binary (base 2). The base of a number is also known as its ______.
radix
When ___________ are compared with ==, the result is true if both references refer to the same object in memory.
references
____________ compares portions of two Strings for equality
regionMatches
A _________________ is a specially formatted String that describes a search pattern for matching characters in other Strings.
regular expression
If a quantifier is followed by a question mark (?), the quantifier becomes ____________ (sometimes called _____).
reluctant, lazy
Method _______________ returns a new String object in which every occurrence of the first char argument is replaced with the second.
replace
String method ______________ replaces text in a String with new text (the second argument) wherever the original String matches a regular expression (the first argument).
replaceAll
Sometimes it's useful to replace parts of a string or to split a string into pieces. For this purpose, class String provides methods ________________, ____________ and __________________.
replaceAll, replaceFirst, split
String method ________________ replaces the first occurrence of a pattern match.
replaceFirst
Method _____________ reverses the contents of the StringBuilder.
reverse
Append the string s2 to the string s1, using +=
s1 += s2
compare the string s1 to the string s2 for equality of contents.
s1.equal(s2)
Determine the length of the string in s1.
s1.length()
Method _________________ takes an integer and a character argument and sets the character at the specified position in the StringBuilder to the character argument.
setCharAt
Method ____________ increases or decreases the length of a StringBuilder.
setLength
A string may include letters, digits and various _______________, such as +, -, *, / and $.
special characters
String method ____________ breaks a String into its component tokens and returns an array of Strings.
split
To match a set of characters that does not have a predefined character class, use ___________________.
square brackets, []
String methods ______________ and _____________ determine whether strings start with or end with a particular set of characters
startsWith, endsWith
Class String provides two ______________ methods to enable a new String object to be created by copying part of an existing String object. Each method returns a new String object
substring
Method __________ creates a new character array containing a copy of the characters in the String.
toCharArray
Method ____________ returns a new String object with lowercase letters.
toLowerCase
Method _______________ converts a character to its lowercase equivalent.
toLowerCase
Method ___________ of class StringBuilder returns the StringBuilder contents as a String.
toString
Method ___________ returns the String representation of the char value stored in the object.
toString
Method ____________ converts a character to its uppercase equivalent.
toUpperCase
Method ___________________ generates a new String with uppercase letters.
toUpperCase
When you read a sentence, your mind breaks it into _________ --individual words and punctuation marks that convey meaning. Compilers also perform tokenization.
tokens
Method _____ generates a new String object that removes all whitespace characters that appear at the beginning or end of the String on which trim operates.
trim
Java provides eight ______________ classes that enable primitive-type values to be treated as objects: Boolean, Character, Double, Float, Byte, Short, Integer and Long
type-wrapper classes
Class String provides static _______________ methods that take an argument of any type and convert it to a String object.
valueOf
A ______________ character is a space, a tab, a carriage return, a newline or a form feed.
white-space
A _______________ is any letter (uppercase or lowercase), any digit or the underscore character.
word character