Strings Flashcards
1
Q
What is concatenation?
A
Strings can be joined together to form new strings. That’s concatenation. It’s often done using the ‘+’ operator.
2
Q
What are upper, lower, length and subStrings called and what do they act on?
A
They’re special functions called methods. They act on a particular object and are called using the object’s name followed by a dot and the method’s name.
3
Q
What is x.upper?
A
- Changes all characters in string x to upper case.
- e.g. HELLO
4
Q
What is x.lower?
A
- Changes all characters in string x to lower case.
- e.g. hello
5
Q
What is x.length?
A
- Returns the number of characters in string x.
- e.g. 5
6
Q
What is x[i]?
A
- Extracts the character in position i from string x
- e.g. x[1] = “e”
7
Q
What is x.subString(a,b)?
A
- Extracts a string starting at position a with length b from string x.
- e.g. x.subString(3,2) = “lo”