Engineering Problem Solving With C++ 4th Edition Etter Test Bank Download

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Engineering Problem Solving with C++, 3e Chapter 5 Test Bank

Engineering Problem Solving With C++ 4th


Edition by Etter Ingber ISBN 0134444299
9780134444291
Download solution manual at:
https://testbankpack.com/p/solution-manual-for-engineering-
problem-solving-with-c-4th-edition-by-etter-ingber-isbn-
0134444299-9780134444291/

Download full test bank at :


https://testbankpack.com/p/test-bank-for-engineering-problem-
solving-with-c-4th-edition-by-etter-ingber-isbn-0134444299-
9780134444291/

1. The class name used to declare an input file stream is …


A. inFile
B. ifstream
C. iostream
D. istream
2. Which statement must you include to define and use input file streams
A. #include <ifstream>
B. #include <filestream>
C. #include <cstream>
D. #include <fstream>
3. Which of the following statements correctly declares the input file object MyInput and
initializes the file object to stream from the file exam.txt?
A. ifstream MyInput("exam.txt");
B. MyInput ifstream("exam.txt");
C. ifstream MyInput(exam.txt);
D. MyInput ifstream(exam.txt);

4. Which of the following statements correctly opens the output file myanswers.txt?
A. AnsFile.open("myanswers.txt");
B. open.AnsFile("myanswers.txt");
C. open.AnsFile(myanswers.txt);
D. AnsFile.open(myanswers.txt);

©2017 Pearson Education, Inc. Hoboken, NJ. All Rights Reserved.


Engineering Problem Solving with C++, 3e Chapter 5 Test Bank

5. Which of the following statements will properly store the value of the variable value into the
output file object AnsFile?
A. AnsFile << value;
B. AnsFile << cout << value;
C. cout << AnsFile << value;
D. store.AnsFile(value);
6. Read a value from the input file stream MyInput and assign it to the variable value
A. MyInput >> value;
B. MyInput >> cin >> value;
C. cin >> MyInput >> value;
D. value = read.MyInput();

©2017 Pearson Education, Inc. Hoboken, NJ. All Rights Reserved.


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?
A. close.AnsFile;
B. "myanswers.txt".close;
C. AnsFile.close();
D. AnsFile.close("myanswers.txt " );
8. Which of the following repetition statements will properly repeat while not at the end of the
data file associated with the object DataFile
A. while( ! DataFile)
B. while ( ! eof())
C. while ( ! DataFile.eof())
D. while ( ! eof.DataFile())
9. Use which of the following methods to recover from an input file error?
A. undo();
B. reset();
C. recover();
D. None of the above.
10. Which of the following conditions will put an input filestream object into the fail state?
A. Opening a file which already exists and is in the same directory as the program.
B. Opening a file which does not already exist, or is not in the same directory as the
program.
C. Trying to read an integer when the next character in the file is the /n.
D. All of the above will put the file object into the fail state.

11. Given the statement outFile.open("yourAnswers.txt”); and the output file yourAnswers.txt
already exist …
A. The file object is placed into the fail state.
B. A warning message will be printed and any output sent to the file will overwrite the
existing information in the file,
C. No warning or error message is printed and any output sent to the file will overwrite the
existing information in the file.
D. Any information sent to the file will be appended to the existing information in the file.
12. Given that the name of an existing file has been stored in the string filename, which of the
following statements will correctly open the file.
A. inFile.open(filename);
B. inFile.open(str.filename);
C. inFile.open(‘filename’);
D. inFile.open("filename");

13. In the istream class hierarchy, ifstream inherits from, or is a subclass of, the class istream.
A. True
B. False

©2017 Pearson Education, Inc. Hoboken, NJ. All Rights Reserved.


Engineering Problem Solving with C++, 3e Chapter 5 Test Bank

14. A blank character can be input and stored into character variable c using the statement:
cin >> c;
A. True
B. False
15. The peek() method can be used to examine the next character in the input stream, without
actually removing it from the input stream.
A. True
B. False
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.
A. True
B. False

17. When an open statement is successful the stream state flag goodbit is set to 1.
A. True
B. False

18. C++ iostream class inherits from both the istream and ostream classes.
A. True
B. False
19. If you have overloaded an ostream operator, which of the following are possible left-hand
operands:
A. cout
B. cerr
C. an instance of ofstream
D. all of the above.

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.
A. True
B. False

21. If an error occurs when reading from an istream, the fail bit is set on the stream and
execution of the program stops.
A. True
B. False
22. By default, C++ ofstream objects are opened in overwrite mode.
A. True
B. False
23. No prior knowledge of a file’s structure is needed to be able to read the file in C++.
A. True
B. False
24. Errors may occur when attempting to read data that is not of an appropriate type.

©2017 Pearson Education, Inc. Hoboken, NJ. All Rights Reserved.


Engineering Problem Solving with C++, 3e Chapter 5 Test Bank

A. True
B. False
25. Select ALL of the following that are considered whitespace:
A. The blank character.
B. The tab character.
C. The newline character.
D. The carriage return character.
E. The form feed character.

©2017 Pearson Education, Inc. Hoboken, NJ. All Rights Reserved.

You might also like