Engineering Problem Solving with C++, 3e Chapter 5 Test Bank
1. The class name used to declare an input file is …
2. Which include statement must you use to define and use input file streams
3. Which of the following statements correctly declares the input file object MyInput and
4. Which of the following statements correctly opens the output file myanswers.txt ?
5. Which of the following statements will properly store the value of the variable value into the
Engineering Problem Solving with C++, 3e Chapter 5 Test Bank
7. Which of the following statements will close the output file associated with the object
AnsFile?
8. Which of the following repetition statements will properly repeat while not at the end of the
data file associated with the object DataFile
9. Use which of the following methods to recover from an input file error?
10. Which of the following conditions will put the input filestream object into the fail state?
11. Given the statement outFile.open(“yourAnswers.txt); and the output file yourAnswers.txt
already exist …
12. Given the name of the file you want to open has been stored in the string object filename,
which of the following will statements will correctly open the file.
14. A blank character can be input and stored into character variable c using the statement:
cin >> c;
15. The peek() method can be used to examine the next character in the input stream, without
16. When an input file encounters an input error and goes into the fail state an error message is
automatically generated and displayed on the output screen.
17. When an open statement is successful the stream state flag goodbit is set to 1.
19. If you have an overloaded output operator that can send data to an ostream, which of the
following are possible left-hand operands to the operator:
20. Derived classes like ifstream may only use inherited methods from the parent (base) class;
therefore ifstream has no specialized methods for working with files.
21. When an error occurs when reading from an istream, the fail bit is set on the stream and
execution of the program stops.
23. No prior knowledge of a file’s structure is needed to be able to read the file in C++.