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

Test Bank for C++ How to Program: Late Objects Version, 7/E 7th Edition : 0132165414

Test Bank for C++ How to Program: Late Objects


Version, 7/E 7th Edition : 0132165414

To download the complete and accurate content document, go to:


https://testbankbell.com/download/test-bank-for-c-how-to-program-late-objects-versio
n-7-e-7th-edition-0132165414/

Visit TestBankBell.com to get complete for all chapters


C++ How to Program, 7/e Multiple Choice Test Bank 1 of 2

Chapter 8: Sequential-Access Files

Section 8.2 The Data Hierarchy

8.2 Q1: Select the false statement.


a. All data items can eventually be reduced to a sequence of 0s and 1s.
b. A binary digit (bit) can store two values simultaneously.
c. It is cumbersome to work with data in bit form.
d. It is easiest to produce electronic devices that can assume one of two stable states.
ANS b. A binary digit (bit) can store two values simultaneously.

8.2 Q2: Which statement is not true about 0, z , %, * and Q?


a. Each can be represented in terms of 0s and 1s.
b. Each is a character.
c. Only three of the elements listed are in typical character sets.
d. Each can be represented as a byte.
ANS c. Only three of the elements listed are in typical character sets.

8.2 Q3: The data hierarchy, arranged from smallest to largest, is:
a. Bit, byte, record, field, file.
b. Byte, bit, field, record, file.
c. Bit, byte, field, record, file.
d. Byte, bit, field, file, record.
ANS c. Bit, byte, field, record, file.

8.2 Q4: Typically, which of the following contains the most data?
a. A database.
b. A file.
c. A byte.
d. A field.
ANS a. A database.

Section 8.3 Files and Streams

8.3 Q1: Which of the following does not have a stream associated with it?
a. cerr.
b. cin.
c. cout.
d. All of the above have streams associated with them.
ANS c. All of the above have streams associated with them.

8.3 Q2: In order to perform file processing in C++, which header files must be included?
a. <cstdio> , <iostream> and <fstream>.
b. <cstdio> and <iostream>.
c. <cstdio> and <fstream>.
d. <iostream> and <fstream>.
ANS d. <iostream> and <fstream>.

Section 8.4 Creating a Sequential File

8.4 Q1: Select the false statement.


a. C++ imposes no structure on a file.
b. C++ files include information about their structure.
c. The programmer must impose a structure on a file.

© Copyright 1992-2011 by Deitel & Associates, Inc. and Pearson Education, Inc. All Rights Reserved.
Test Bank for C++ How to Program: Late Objects Version, 7/E 7th Edition : 0132165414

C++ How to Program, 7/e Multiple Choice Test Bank 2 of 2

d. C++ files do not understand notions such as “records” and “fields.”


ANS b. C++ files include information about their structure.

8.4 Q2: Which file open mode would be used to write data only to the end of an existing file?
a. ios::app
b. ios::in
c. ios::out
d. ios::trunc
ANS a. ios::app

8.4 Q3: When used with ofstream objects, operator! is not:


a. Overloaded.
b. Used to determine if the open operation succeeded.
c. Used to close a file explicitly.
d. Used to return a nonzero value if an error occurs.
ANS c. Used to close a file explicitly.

Section 8.5 Reading Data from a Sequential File

8.5 Q1: Which of the following will not change the file-position pointer to the same position as the others? Assume
a 10-byte file size and a current position at byte # 1.
a. fileObject.seekg( 2 );
b. fileObject.seekg( 1, ios::cur );
c. fileObject.seekg( 2, ios::beg );
d. fileObject.seekg( 8, ios::end );
ANS d. fileObject.seekg( 8, ios::end );

8.5 Q2: What is not true about this code segment?

location = fileObject.tellg();

a.tellg is a member function of fileObject.


b.location is a pointer.
c.The value of location after the segment executes must be less than or equal to the number of bytes in
the file attached to fileObject.
d. fileObject is an istream object.
ANS b. location is a pointer.

Section 8.6 Updating Sequential Files

8.6 Q1: Which of the following is not a disadvantage of trying to modify a sequential access file?
a. Modifying data can potentially destroy other data.
b. It may be necessary to rewrite every record in the file to make a slight change.
c. Things that are stored in the same number of “raw data” bytes internally may not take up the same amount
of space in a file.
d. Overwriting a record with another record of the same size is very difficult.
ANS: d. Overwriting a record with another record of the same size is very difficult.

© Copyright 1992-2011 by Deitel & Associates, Inc. and Pearson Education, Inc. All Rights Reserved.

Visit TestBankBell.com to get complete for all chapters

You might also like