Midterm OOP - Lesson 5 Flashcards

String Methods

1
Q

A sequence of characters

A

String

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

Immutable because it is a constant and cannot be changed once created

A

String

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

Syntax on how to declare a String:
String Literal

A

String x = “Hello World”;

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

Syntax on how to declare a String:
String Constructor

A

String x = new String(“Hello World”);

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

Syntax on how to declare a String:
String Builder - used in .reserve() method

A

StringBuilder x = new StringBuilder(“Hello World”);

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

True or False
STRING INDEXING:
Must start with zero (0) the same as array indexing

A

Truuuu

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

True or False
STRING INDEXING:
You need to include the whitespace while counting

A

True

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

True or False
STRING INDEXING:
Counting the characters in a String must start to zero(0)

A

False :
counting the characters in a String must start to one(1)

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

STRING METHODS: Returns integer corresponds to the number of characters in the String including whitespace.

A

.length()

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

STRING METHODS: Returns Boolean that used to compare two or more String statement in exact casing.

A

equals(String)

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

STRING METHODS: Returns Boolean that used
to compare two or more String statement ignoring case consideration.

A

.equalsIgnoreCase(String)

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

String Methods: – convert all the characters in the String to uppercase.

A

.toUpperCase()

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

String Methods:convert all the characters in the String to lowercase.

A

.toLowerCase()

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

String Methods: Concatenate specified String to the end of another String.

A

.concat(String)

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

String Methods:returns a copy of the String by removing any whitespaces.

A

.trim()

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

String Method: Returns a character at specified index

A

charAt(int/index)

17
Q

String Method: Returns the substring from the specified index up to the end index of the string.

A

.substring(int)

18
Q

String Method: Returns the substring from the specified index up to the another specified index of the string.

A

.substring(int, int)

19
Q

String Method: Returns a new String by replacing all
occurrence of the specified old characters to new specified characters.

A

.replace(old String, new String)

20
Q

String Method: Returns a new String by
replacing the first occurrence of the specified old characters to new specified characters.

A

replaceFirst (old String, new String)

21
Q

String Method: Reverse the whole String

A

.reserve()