Question 1. _____ are files to which data is written.
Output files
Input files
Active files
Sequential files
Question 2. When storing and retrieving data, a sequential access file is much like a _____.
floppy disk
book
hard disk
VCR tape
Question 3. Once you finish using a file, you should _____ it.
exit
append
close
output
Question 4. The header file that defines the classes for processing and manipulating files is called the _____.
Question 5. What do the following statements accomplish?
ofstream theFile;
theFile.open( myFile.txt , ios::out);
Opens myFile in read mode
Opens myFile in append mode
Creates an empty file named myFile
Opens a file in input mode to write to
Question 6. When a file is opened in output mode, the file pointer is positioned _____.
at the end of the file
at the beginning of the file
in the middle of the file
after the file header
Question 7. Which of the following functions should be used to determine if a file was successfully closed?
is_active
is_open
is_closed
is_ready
Question 8. What is the data hierarchy arranged from largest to smallest?
File, field, record, byte, bit
File record, field, bit, byte
File, record, field, byte, bit
Record, file, field, bit, byte
Question 9. To use an input file, the program must include _____.
fstream
instream
outstream
filestream
Question 10. Which of the following is not true about files?
C++ views each file as a sequential stream of bytes.
Files are opened by creating objects of stream classes.
Member functions of stream objects can be applied to file streams.
istream, ostream, and iostream are derived from ifstream, ofstream, and fstream, respectively.
Question 11. Compare and contrast the mode operators ios::in, ios::app, and ios::out. Provide a C++ code segment that illustrates the use of these mode operators.