String and Stream Tokenizer

String tokenizer contains useful methods that can be used to isolate the tokens. StringTokenizer provides two methods that are very effective for the processing string. These methods are countToken and nextToken. To use methods of the class StringTokenizer, user needs to create object of this class. This class provides two constructors to create its object. StringTokenizer can be used to process input from a file line by line. While reading an input string supplied by a user, it is analysed token-by-token.  To isolate the tokens StringTokenizer class is used, which is found in the package java dot util. Streamtokenizer is a predefined class which parses the input stream into the tokens. This class is contained in java.util package. StreamTokenizer class also provides four static int variables to check the token type.

To Access the full content, Please Purchase

  • Q1

    Name two variables of class StreamTokenizer.

    Marks:1
    Answer:

    double nval and String sval

    View Answer
  • Q2

    Which package does class StringTokenizer belong to?

    Marks:1
    Answer:

    java.util

    View Answer
  • Q3

    What is the use of the class StringTokenizer?

    Marks:1
    Answer:

    It is used to break strings into tokens.

    View Answer
  • Q4

    What is a ‘separator’?

    Marks:1
    Answer:

    A separator may be a string or a character that separates the tokens within a sequence.

    View Answer
  • Q5

    What do you mean by the term ‘Token’?

    Marks:1
    Answer:

    Tokens are different values within a string, which are individually meaningful.

    View Answer