The StringTokenizer class in Java (in java.util package) is used to break a string into tokens or smaller parts, based on a specified delimiter. It’s useful for simple string parsing, although modern alternatives like split() or Scanner are preferred in newer Java versions.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
What is the default delimiter used by StringTokenizer?
Correct
Incorrect
Question 3 of 15
3. Question
Which constructor creates a tokenizer with custom delimiter?
Correct
Incorrect
Question 4 of 15
4. Question
What does hasMoreTokens() do?
Correct
Incorrect
Question 5 of 15
5. Question
Which method is used to get the next token from a StringTokenizer?
Correct
Incorrect
Question 6 of 15
6. Question
What happens if nextToken() is called with no tokens left?
Correct
Incorrect
Question 7 of 15
7. Question
Which method tells how many tokens are left?
Correct
Incorrect
Question 8 of 15
8. Question
Is StringTokenizer synchronized?
Correct
Incorrect
Question 9 of 15
9. Question
What is a limitation of StringTokenizer?
Correct
Incorrect
Question 10 of 15
10. Question
Which method allows changing delimiter dynamically?
Correct
Incorrect
Question 11 of 15
11. Question
What is the return type of nextToken()?
Correct
Incorrect
Question 12 of 15
12. Question
Which of the following is better for complex parsing?
Correct
Incorrect
Question 13 of 15
13. Question
Can StringTokenizer handle multiple delimiters?
Correct
Incorrect
Question 14 of 15
14. Question
What is the output of: new StringTokenizer(“Java|Python|C”, “|”).countTokens()?
Correct
Incorrect
Question 15 of 15
15. Question
Which of these classes is the modern alternative to StringTokenizer?
Correct
Incorrect
Summary
The StringTokenizer class in Java is a legacy parser used to split strings into tokens based on delimiters. It’s simple, thread-safe, and works well for basic tokenization. However, for regex-based or more complex splitting, prefer modern alternatives like String.split() or Scanner.
At QuizOrbit, our team specializes in fun, informative quizzes across topics like general knowledge, technology, and entertainment. Boost your knowledge with our expert-designed quizzes.