File Handling (NCO)

datafile handling

14 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which of the following files in C++ is a file that contains information in the same format in which the information is held in the memory?

  1. Binary file
  2. Text file
  3. ASCII file
  4. Data file
  5. filebuf
Question 2 Multiple Choice (Single Answer)

Which of the following classes in C++ supports output operations and contains open() function with default output mode?

  1. fstreambase
  2. ifstream
  3. ofstream
  4. fstream
  5. filebuf
Question 3 Multiple Choice (Single Answer)

Which of the following streams in C++ receives data from a program and writes the data to a monitor that it receives from the program?

  1. Input stream
  2. Output stream
  3. Error stream
  4. File
  5. Data stream
Question 4 Multiple Choice (Single Answer)

Which of the following codes is used for relative position in get pointer and is used to place the file pointer, and read the contents from the beginning of a file?

  1. ios::cur
  2. ios::beg
  3. ios::end
  4. ios::out
  5. ios::in
Question 5 Multiple Choice (Single Answer)

Which of the following file modes is used in file handling, if an already existing file is to be opened for output operations and its previous contents are to be deleted by a new one?

  1. ios::app
  2. ios::ate
  3. ios::binary
  4. ios::trunc
  5. ios::out
Question 6 Multiple Choice (Single Answer)

Which of the following operators in C++ is called as an insertion operator that inserts data into an appropriate stream?

  1. >>
  2. <<
  3. :?
  4. &
  5. *
Question 7 Multiple Choice (Single Answer)

Which of the following program codes is correct for opening a file in append mode that sets the write pointer to end of a file?

  1. fstream f1;
    f1.open(TEXT.DAT, ios::app);
  2. ifstream f1;
    f1.open(TEXT.DAT, ios::app);
  3. ofstream f1;
    f1.open(TEXT.DAT, ios::trunc);
  4. fstream f1;
    f1.open(TEXT.DAT, ios::out);
  5. fstream f1;
    f1.open(TEXT.DAT, ios::in);
Question 8 Multiple Choice (Single Answer)

Which of the following steps is the first step to use files in C++?

  1. Declaring file streams
  2. Including the header files
  3. Opening a file
  4. Process the file
  5. Closing a file
Question 9 Multiple Choice (Single Answer)

Which of the following stream classes is used in C++ to perform input and output operations on to a data file?

  1. istream
  2. ostream
  3. ifstream
  4. ofstream
  5. fstream
Question 10 Multiple Choice (Single Answer)

Which of the following functions in data file handling moves the file put pointer to a location specified by its arguments?

  1. seekg()
  2. tellg()
  3. tellp()
  4. seekp()
  5. return()
Question 11 Multiple Choice (Single Answer)

Which of the following stream classes acts as base class in the hierarchy of file stream classes?

  1. istream
  2. ostream
  3. iostream
  4. ios
  5. fstream
Question 12 Multiple Choice (Single Answer)

Which of the following functions is used to write the contents of the binary file associated with ofstream object?

  1. read()
  2. write()
  3. tellg()
  4. tellp()
  5. seekg()
Question 13 Multiple Choice (Single Answer)

Which of the following devices is connected to the input stream in C++ from which data is extracted and provided to the program for manipulation?

  1. Monitor
  2. Printer
  3. Keyboard
  4. Plotter
  5. Joystick
Question 14 Multiple Choice (Single Answer)

Consider the following C++ code:

textfile.open(sample.dat, ios::in);

Where is the get pointer placed after the execution of the above code?

  1. At the beginning of the file
  2. At the end of the file
  3. In the middle of data file
  4. At the current position of data file
  5. Automatically positioned