Page 376 - Cs_withBlue_J_C11_Flipbook
P. 376

6.  Which of the following is a collection of related fields?
                    a.  File                                        b.  Field
                    c.  Record                                      d.  All of these
                  7.  Which of the following is the class inherited by FileInputStream class?
                    a.  InputStream                                 b.  DataInputStream
                    c.  File                                        d.  StreamInput
                  8.  Which of the following methods is used to write String data to a binary file?
                    a.  write()                                     b.  writeui()
                    c.  writeString()                               d.  writeUTF()
                  9.  Which of the following is used to read a line of text from a text file?
                    a.  readLine()                                  b.  read
                    c.  readUTF()                                   d.  readString()
                 10.  Temporary storage area is called a ………………… .
                    a.  Reader                                      b.  Writer
                    c.  File                                        d.  Buffer

                Answers
                   1.  b     2.  c    3.  a     4.  d     5.  b     6.  c     7.  a     8.  d     9.  a     10.  d


              B.  Fill in the blanks:
                  1.  ………………… method is used in the Scanner class to include more delimiters.
                  2.  ………………… method is used in the Scanner class to input boolean data.
                  3.  System is a final ………………… defined in java.lang package.
                  4.  ………………… method of StringTokenizer class returns the next token.
                  5.  .mp4, .mov, .flv are files of ………………… type.
                  6.  ………………… class creates an object and connects to the physical file for writing data to a text file.
                  7.  ………………… method is used to close stream objects.
                  8.  ………………… class has the print() method to write data to a text file.
                Answers
                  1.  Delimiter()           2.   nextBoolean()          3.   class             4.   nextToken()
                  5.   Video                6.   FileWriter             7.   close()           8.   PrintWriter


              C.  Answer the following questions:
                  1.  Write the different methods of the Scanner class to scan input.
                Ans.  The different methods of Scanner class are:
                                Method                         Purpose
                     nextInt()                     It reads an integer value.
                     nextFloat()                   It reads a float value.
                     nextDouble()                  It reads a value of type double.
                     nextLong()                    It reads a value of type long.
                     nextBoolean()                 It reads a boolean value.
                     nextLine()                    It reads a string.
                     next()                        It reads a word.
                  2.  Write the steps to read data from a Binary file.
                Ans.  Step 1: Create objects of FileInputStream and connect it with the physical file on the disk.
                    Step 2:  Connect the FileInputStream object with the DataInputStream objects to call the required methods for reading data of
                          different primitive types.



                374374  Touchpad Computer Science-XI
   371   372   373   374   375   376   377   378   379   380   381