Page 385 - Cs_withBlue_J_C11_Flipbook
P. 385

B.  Fill in the blanks:
                    1.  The ………………… method is used in the Scanner class to input long type data.
                    2.  The ………………… method is used in StringTokenizer class to count the number of tokens.
                    3.  Sorting of records can be done in ………………… and ………………… order.
                    4.  A ………………… parameter opens a file in append mode.
                    5.  ………………… class handles data in bytes.
                    6.  The ………………… method is used to write float type data in a binary file.
                    7.  Character stream can handle ………………… characters.
                    8.  ………………… class is the base class of FileWriter class.

                 C.  Answer the following questions:
                    1.  Define the following methods of StringTokenizer class:
                       a.  hasMoreTokens()
                       b.  nextToken()
                       c.  countTokens()
                    2.  Write the steps to write data to a binary file.
                    3.  Write the steps to read data from a text file.
                    4.  Define the overloaded constructors of the StringTokenizer class.
                    5.  Differentiate between binary and text files.
                 D.  Unsolved Programs:
                    1.  Define a class Bank having the following class description:
                        Data Members
                        AccountNo                    :   To store account number of customer type integer
                        Name                         :   To store account holders name of String type
                        Principal                    :   To store the amount in the bank
                        Pan                          :    To store the Pan number of the customer
                        Member Methods
                        void createFile()            :   Creates a binary file BANK.dat having the above fields
                        void printRec()              :   Print the details of the customers
                        void withdraw()              :   Updates balance when the amount is withdrawn from the account
                        void deposit()               :   Updates balance when the amount is deposited to the account
                        static void main()           :   Writes a menu-driven program to perform the following file operations
                    2.  Define a class called Paragraph to perform read and write operations on a text file “Para.dat”. The detail of the class is given as
                       follows:
                        Data Members
                        String pline                 :   To store lines of a paragraph
                        Member Methods
                        void createFile()            :   Accepts five lines of a poem and stores it in a text file “Para.dat”
                        void countWrd()              :  Reads the text file “Para.dat” and counts and prints the palindromic words in the string.
                                                        (Palindromic words are those words that are same when read from both the ends.)
                        static void main()           :   Creates the object and executes other methods
                 E.   Assertion and Reasoning Based Question.
                    Assertion: Conditional Assignment Operator is also known as Ternary Operator.
                    Reason: Ternary Operator consists of three operands which can be a variable, an expression or a constant.
                    (a)  Both Assertion and Reason are true, and Reason is the correct explanation for
                    (b)  Both Assertion and Reason are true, but Reason is not the correct explanation for Assertion.
                    (c)  Assertion is true and Reason is false.
                    (d)  Assertion is false and Reason is true.



                                                                                                                       383
                                                                                 Basic Input/Output and Data File Handling    383
   380   381   382   383   384   385   386   387   388   389   390