Page 375 - Cs_withBlue_J_C11_Flipbook
P. 375
The output of the preceding program is as follows:
Enter lines of a poem
The divine breeze
Enter lines of a poem
The blooming trees
Enter lines of a poem
The divine sound of humming bees
Enter lines of a poem
I am lost in nature
Enter lines of a poem
Divine bliss.
Divine occurs 3 times
Let’s Revisit
♦ Scanner class is used to read input from keyboard for different primitive data types.
♦ PrintStream class converts output data of primitive type to text and writes it to the output stream.
♦ StringTokenizer is a class which is used to split a String into tokens.
♦ A file is a named location that can be used to store related information permanently in a secondary storage device.
♦ Byte stream classes are used for byte-oriented IO and character stream classes are used for character-oriented IO.
♦ The close() method is used to close the stream objects.
MIND DRILL
Solved Questions
A. Tick ( ) the correct option:
1. Scanner class belongs to ………………… package in Java.
a. java.io b. java.util
c. java.net d. java.lang
2. Which of the following methods is used to scan int type data in the Scanner class?
a. nextInteger() b. NextInt()
c. nextInt() d. nextUTF
3. Tokens are separated by characters called ………………… .
a. Delimiters b. Carriage return
c. Escape sequence characters d. New line
4. Which of the following characters is added by the println() method after printing?
a. null b. ‘\0’
c. ’\r’ d. ‘\n’
5. Which of the following is the return type of the countTokens() method in StringTokenizer class?
a. boolean b. int
c. String d. char
373
Basic Input/Output and Data File Handling 373

