Chapter 7 Flashcards

1
Q

What is each created string?

A

A class object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What happens when you use “==” with strings?

A

Comparing computer memory locations, not their values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a literal string?

A
  • A sequence of characters enclosed within double quotation marks
  • An unnamed object, or anonymous object, of the string class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a string variable?

A
  • A named object of the string class
  • A reference variable
  • Refers to a location in memory rather then to a particular value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What happens when you try to assign a new value to a String?

A
  • The adress held by the string is altered
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are immutable objects?

A
  • Objects taht cannot be changed, such as a String
  • After a string is created, it is Immutable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the Equals() method?

A
  • Returns the content of the two String objects to determine if they are equivalent
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the equalsIgnoreCase() method?

A
  • Ignore case when determining if two strings are equivilant
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the compareto() method?

A
  • Compares two Strings and returns:
  • Zero: if the two strings refer to the same value
  • Negative Number: if the calling object is “less than” the argument
  • Positive number: “If the calling object is “more than” the argument
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are empty strings?

A
  • Reference a memory adress with no characters
  • Can be used in string methods
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are null strings?

A
  • Use the null java keyword
  • Strings are set to null by default
  • Cannot be used in String methods
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the toUpperCase() and toLowerCase() methods?

A
  • Convert any styring to its uppercase or lowercase equivilant
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the Length() method?

A

Returns the length of a string?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the indexOf() method?

A
  • Determins weather a specific character occurs within a string
  • Returns the position of the character
  • The return value is -1 if the character does not exist in the String
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the charAt(0 method?

A

returns the character at the specified index in a string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the endsWith() and startsWith() method

A
  • Each takes a String argument
  • Returns true of false if a String object does or does not start or end with the specified argument, respectively
17
Q

What is the -replace() method?

A
  • Replaces all occurances of some character within a string
18
Q

What is the contains() method?

A
  • Allows you to determine whether one string contains another
  • Case sensitive
19
Q

What is the toString() method?

A
  • Converts any object to a string
  • Converts primitive data types to Strings
20
Q

What is the Substring() method?

A
  • Extracts part of a String
  • Takes two integer arguments: start and end position
  • The length of the extracted substring is the difference between the second integer and the first integer
21
Q

What is the regionMatches() method?

A
  • Two variants that can be used to test if two String regions are equal
  • In one, a substrict of the specified String object is compared to the substring of the other
  • If the substrings contain the same character sequence, then the expression is true, otherwise false
  • Second version uses additional boolean argument to determine whether case is ignored when comparing characters
22
Q

What is the StringBUilder and StringBuffer classes?

A
  • Alternative to string
  • Used when a string will be modified
  • Use anywhere you would use a string
23
Q

What are the differences between StringBuilder and StringBuffer classes?

A
  • StringBuildeer = more efficient
  • StringBuffer = Thread safe; used in multithreaded program
24
Q

What is a buffer?

A
  • A memory block
  • Might or might not contain a string
  • The string might not occupy the entire buffer
  • The length of a string can be different from the length of the buffer
25
Q

What is capacity?

A

The actual length of the buffer

26
Q

What is the append() method?

A

Adds characters to the end of a stringBuilder object

27
Q

What is the insert() method?

A

Adds characters at a specific location within a StringBuilder object

28
Q

What is the SetChar() method?

A

Changes a character at a specified position within a StringBuilder object