Page 316 - ComputerScience_Class_11
P. 316
Let’s Revisit
♦ Strings refer to the combination of different characters including alphabets, digits, punctuators and/or special symbols.
♦ The Character is a built-in class in Java that provides various methods to manipulate characters.
♦ The StringBuffer class is used to create sufficient space in the memory to store a String.
♦ The StringTokenizer class splits the given string into tokens (sequence of characters except delimiters) or words.
MIND DRILL
Solved Questions
A. Tick ( ) the correct option.
1. "India" is an example of a ………………….
a. char b. String
c. int d. boolean
2. What data type does Character.isLetter(char) return?
a. boolean b. char
c. String d. int
3. For a string variable, which method returns the character at the given index?
a. length() b. indexOf()
c. charAt() d. substring()
4. What does toLowerCase() function do?
a. It converts the lowercase letters to capital letters. b. It converts the uppercase letters to lowercase letters.
c. It removes the lowercase letters. d. It reverses the characters.
5. The function append() ………………….
a. adds a string to the beginning of another string. b. concatenates a string at the end of another string.
c. replaces one character with another character. d. inserts a string into another string in the middle.
Answers
1. b 2. a 3. c 4. b 5. b
B. Fill in the blanks.
1. A ………………… is a combination of a set of characters written within double quotes.
2. ………………… class splits the given string into tokens.
3. ………………… returns the next token/word from the StringTokenizer object.
4. ………………… function is used to delete the leading and trailing spaces from the string of the current object.
5. We use the ………………… method to reverse the characters in the given string.
Answers
1. string 2. StringTokenizer 3. nextToken() 4. trim() 5. reverse()
C. Answer the following questions:
1. What is the use of the startsWith() function of the String class?
Ans. The startsWith() function checks whether the string in the current object starts with the string given as parameter. This function
returns a Boolean type value.
314 Touchpad Computer Science (Ver. 3.0)-XI

