Strings Flashcards
What does the indexOf()
method do?
a) It returns the last occurrence of a character in a string
b) It returns the first occurrence of a character in a string
c) It returns the middle occurrence of a character in a string
d) It returns the length of the string
b) It returns the first occurrence of a character in a string
What does the substring()
method return if it is provided with only a start index?
a) The string from the start index to the end
b) The entire string
c) A substring that excludes the start index
d) The string from the middle to the start
a) The string from the start index to the end
Which method is used to convert the first letter of a name to uppercase?
a) toUpperCase()
b) charAt()
c) substring()
d) properCase
d) properCase
What happens if toUpperCase()
is used on a string that is already in uppercase?
a) It throws an exception
b) It converts the string to lowercase
c) It has no effect on the uppercase letters
d) It duplicates the uppercase letters
c) It has no effect on the uppercase letters
In the email ‘victoria.ploetz@largecorp.com’, what is the character at index 0?
a) v
b) @
c) p
d) l
a) v
How does the substring()
method work when passed two parameters?
a) It returns a substring from the first to the second index
b) It returns the whole string
c) It ignores the first parameter
d) It duplicates the string
a) It returns a substring from the first to the second index
What is the purpose of properCase()
method?
a) It converts the entire string to uppercase
b) It capitalizes the first letter of a string
c) It converts the entire string to lowercase
d) It finds the position of characters in the string
b) It capitalizes the first letter of a string
What is the purpose of the toLowerCase()
method in email processing?
a) To convert the email to lowercase
b) To capitalize the email
c) To check for special characters
d) To reverse the email
a) To convert the email to lowercase
What does the charAt()
method do?
a) It returns the character at a specified index
b) It finds the length of a string
c) It concatenates two strings
d) It converts the string to uppercase
a) It returns the character at a specified index