download Mastguru Android App

C++ File Handling Questions Answers Online Quiz Test

  • 1. Which stream class is to only write on files ?

    1. ofstream
    2. ifstream
    3. fstream
    4. iostream
  • 2. Which stream class is to only read from files ?

    1. ofstream
    2. ifstream
    3. fstream
    4. iostream
  • 3. Which stream class is used to both read and write on files ?

    1. ofstream
    2. ifstream
    3. fstream
    4. iostream
  • 4. Which among following is used to open a file in binary mode ?

    1. ios:app
    2. ios::out
    3. ios::in
    4. ios::binary
  • 5. ios::trunc is used for ?

    1. If the file is opened for output operations and it already existed, no action is taken.
    2. If the file is opened for output operations and it already existed, its previous content is deleted and replaced by the new one.
    3. If the file is opened for output operations and it already existed, then a new copy is created.
    4. None of above
  • 6. Which is correct syntax ?

    1. myfile:open ("example.bin", ios::out);
    2. myfile.open ("example.bin", ios::out);
    3. myfile::open ("example.bin", ios::out);
    4. myfile.open ("example.bin", ios:out);
  • 7. Which among following is correct syntax of closing a file in c++ ?

    1. myfile$close();
    2. myfile@close();
    3. myfile:close();
    4. myfile.close();
  • 8. What is use of eof() ?

    1. Returns true if a file open for reading has reached the next character.
    2. Returns true if a file open for reading has reached the next word.
    3. Returns true if a file open for reading has reached the end.
    4. Returns true if a file open for reading has reached the middle.
  • 9. Which functions allow to change the location of the get and put positions ?

    1. sg() and sp()
    2. sekg() and sekp()
    3. gog() and gop()
    4. seekg() and seekp()
  • 10. offset counted from the current position using ?

    1. ios::curr
    2. ios::cr
    3. ios::cur
    4. ios::current
  • 11. Calling the stream's member function sync() causes an immediate synchronization.

    1. True
    2. False
  • 12. Which among is used for positioning relative to the beginning of a stream ?

    1. ios::start
    2. ios::beg
    3. ios::begin
    4. ios::beginning
  • 13. Which is among following is used to Open a file for output and move the read/write control to the end of the file ?

    1. ios::ate
    2. ios::at
    3. ios::ann
    4. ios::end
  • 14. Which is correct syntax for, position n bytes back from end of fileObject ?

    1. fileObject.seekg(ios::end, n);
    2. fileObject.seekg(n, ios:end );
    3. fileObject.seekg(n, ios::end );
    4. fileObject.seekg(ios:end, n);
  • 15. How to find the position at end of fileObject ?

    1. fileObject.seekg( 0, ios::end );
    2. fileObject.seekg( 0, ios::end );
    3. fileObject.seekg( 0, ios::end );
    4. fileObject.seekg( 0, ios::end );
  • 16. How to get position n bytes forward in fileObject ?

    1. fileObject.seekg( ios::cur, n );
    2. fileObject.seekg( n, ios:cur );
    3. fileObject.seekg( n, ios::cur );
    4. fileObject.seekg( ios:cur, n );
  • 17. How to get position to the nth byte of fileObject ?

    1. fileObject.seekg( 'filename',n );
    2. fileObject.seekg( n, 'filename' );
    3. fileObject.seekg( n );
    4. fileObject.seekg( n, ios::app );
  • 18. eof() is used to get

    1. easy code reivew
    2. end of file
    3. debug report
    4. file close
Submit Quiz
Post a comment