Character and String Class Methods Flashcards

1
Q

A String variable is not a simple data
type but a reference—it holds a
________________, not the actual
value.

A

memory address

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

Provides methods to manipulate and inspect
single-character data

A

Character class

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

Used to store a single character, such as a
letter, digit, or punctuation mark.

A

Char data type

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

Used for fixed (unchanging) text data made
up of one or more characters.

A

String Class

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

Java also provides a __________ class for working
with characters.

A

Character

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

This class includes useful methods for testing and
manipulating _______________.

A

character values

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

The Character class is part of the _______________, which is automatically imported into every Java program.

A

java.lang
package

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

Java provides tools to make working with text
easier, including classes like ____________ and ____________.

A

Character and String

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

Checks if the given character is a letter
(uppercase or lowercase).

A

isLetter(char ch)

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

Checks if the given character is a digit
(0-9).

A

isDigit(char ch)

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

Checks if the given character is a
whitespace (space, tab, newline, etc.).

A

isWhitespace(char ch)

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

Converts the given character to its
uppercase equivalent.

A

toUppercase(char ch)

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

Converts the given character to its
lowercase equivalent.

A

toLowerCase(char ch)

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

Checks if the given character is an
uppercase letter.

A

isUpperCase(char ch)

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

Checks if the given character is a
lowercase letter.

A

isLowerCase(char ch)

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

Converts the given character to a
String.

A

toString(Char ch)

17
Q

Checks if the given character is a letter
or a digit.

A

isLetterOrDigit(char ch)

18
Q

Compares two characters numerically
based on their Unicode values.

A

compare(char x, char y)

19
Q

compare(char x, char y)

Compares two characters ___________ based on their _________ values.

A

numerically, Unicode

20
Q

_________ are one of the most common
dataType in Java.

21
Q

Strings are __________—they are never
changed.

22
Q

It is a String that uses double quotes with no characters
inside, e.g., String word1 = “ “;.

A

Empty String

22
Q

Returns the number of characters in a String.

23
Q

Finds the position of a character or substring in a String.

24
Returns the character at a specific position.
CharAt()
25
The _________- method takes two integer arguments—a start position and an end position—that are both based on the fact that a String’s first position is position zero.
substring()
26
Checks if a String starts with a specific substring.
startsWith()
27
Checks if a String ends with a specific substring.
endsWith()
28
Replaces all occurrences of a character or String/substring.
replace()
29
Checks if a String contains a specific substring.
contains()
30
Converts current dataType to a String (implicitly used in print() and println()).
toString()
31
Finds the position of a substring starting from a specific index.
indexOf(String, int)
32
Checks if a String is empty or contains only whitespace.
isBlank()
33
Checks if a String has no characters.
isEmpty()
34
Converts the String to lowercase.
toLowerCase()
35
Converts the String to uppercase.
toUpperCase()
36
Removes leading and trailing whitespace.
strip()
37
Removes leading and trailing whitespace (similar to strip() but available in older Java versions).
trim()
38
parseInt() is a _______ method, so you call it using the class name (Integer.parseInt()).
static