C++ For Engineers and Scientists 4th Edition Bronson Test Bank Download
C++ For Engineers and Scientists 4th Edition Bronson Test Bank Download
TRUE/FALSE
1. A file is a collection of data stored together under a common name, usually on a disk.
2. All computer operating systems use the same specification as to the maximum number of characters
permitted for an external filename.
4. Long filenames should be avoided because they take more time to type and can result in typing errors.
6. You must specify a C-string’s maximum length in brackets immediately after it’s declared.
ANS: T PTS: 1 REF: 470
9. In addition to the get() method, all input streams have a set() method for putting the last
character read from an input stream back on the stream.
10. When a program is executed, the standard input stream cin is connected to the standard input device.
MULTIPLE CHOICE
1. A ____ is a collection of data stored together under a common name, usually on a disk, magnetic tape,
USB drive, or CD/DVD.
a. file c. database
b. directory d. file stream object
ANS: A PTS: 1 REF: 462
3. The DOS operating system allows ____ characters plus an optional period and 3-character extension
as the maximum filename length.
a. 4 c. 16
b. 8 d. 32
ANS: B PTS: 1 REF: 462
4. The Excel program adds the ____ extension automatically to all spreadsheet files.
a. .xla or .xls c. .xcl or .xclx
b. .xls or .xlsx d. .wpx or .wpxl
ANS: B PTS: 1 REF: 463
10. The ____ method returns a true value if a file was opened unsuccessfully or a false value if the open
succeeded.
a. fail() c. test()
b. open() d. close()
ANS: A PTS: 1 REF: 466
11. The ____ function is a request to the operating system to end program execution immediately.
a. end() c. terminate()
b. break() d. exit()
ANS: D PTS: 1 REF: 466
12. In declaring and initializing a string variable for use in an open() method, the string is considered a
____.
a. string object c. c_str
b. C-string d. c-character
ANS: B PTS: 1 REF: 469
13. The ____ method breaks the connection between the file’s external name and the file stream object.
a. open() c. bad()
b. fail() d. close()
ANS: D PTS: 1 REF: 473
14. You must check that the ____ method established a connection between a file stream and an external
file successfully because this type of call is a request to the OS that can fail for various reasons.
a. connect() c. open()
b. conn() d. file()
ANS: C PTS: 1 REF: 474
15. C and C++ append the low-value hexadecimal byte ____ as the end-of-file (EOF) sentinel when the
file is closed.
a. 0x01 c. 0x00
b. 0x10 d. 0x11
ANS: C PTS: 1 REF: 477
16. Output file streams can be formatted in the same manner as the ____ standard output stream.
a. cout c. ccout
b. cin d. fout
ANS: A PTS: 1 REF: 478
17. The fstream class’s ____ function permits character-by-character output to a stream.
a. getline() c. putline()
b. get() d. put()
ANS: D PTS: 1 REF: 479
18. A(n) ____ file object is a stream that connects a file of logically related data, such as a data file, to a
program.
a. external c. physical
b. internal d. logical
ANS: D PTS: 1 REF: 484
19. The fstream class’s ____ function is used for character-by-character input from an input stream.
a. get() c. getchar()
b. getline() d. next()
ANS: A PTS: 1 REF: 484
20. All input streams have a ____ function for putting back the last character read from an input stream
back on the stream.
a. put() c. return()
b. putback() d. sendback()
ANS: B PTS: 1 REF: 484
22. The term ____ refers to the process of retrieving data from a file.
a. file connection c. stream connection
b. file access d. stream access
ANS: B PTS: 1 REF: 487
23. The term ____ refers to the way data is stored in a file.
a. file organization c. sequential access
b. file access d. database
ANS: A PTS: 1 REF: 487
24. In ____, any character in the opened file can be read without having to sequentially read all characters
stored ahead of it first.
a. sequential access c. random access
b. sequential organization d. random organization
ANS: C PTS: 1 REF: 487
25. The ____ functions return the file position marker’s offset value.
a. offset() c. seek()
b. where() d. tell()
ANS: D PTS: 1 REF: 488
COMPLETION
1. A(n) ____________________ filename is how the operating system knows the file.
ANS: external
2. Two basic types of files exist: text files, and ____________________ files.
ANS:
binary-based
binary
3. A file stream that receives or reads data from a file to a program is a(n) ____________________ file
stream.
ANS: input
4. For file streams, the direction, or mode, is defined in relation to the ____________________ and not
the file.
ANS: program
5. For each file your program uses, a distinct ____________________ stream object must be created.
ANS: file
6. The ___________________() method returns a false value if the file was opened successfully.
ANS: fail
PTS: 1 REF: 466
7. In using ifstream and ofstream objects, the input or output mode is indicated by the
____________________.
ANS: object
8. In C and C++, the ___________________ sentinel is never counted as part of the file.
ANS:
EOF
eof
end-of-file
end-of-file (EOF)
end of file
9. Reading data from a(n) ___________________-based file is almost identical to reading data from a
standard keyboard.
ANS:
character
text
ANS: clog
11. There are two types of file access: sequential access and ____________________ access.
ANS: random
12. To understand file access types, first you need to understand how data is ____________________ in a
file.
ANS: organized
13. The ____________________() methods allow the programmer to move to any position in a file.
ANS: seek
PTS: 1 REF: 488
14. Using the seek() functions in random access, a(n) ____________________ offset means move
forward in the file.
ANS: positive
15. A file stream object may be passed to a function as long as the function’s formal parameter is defined
as a(n) ____________________ to the appropriate stream.
ANS: reference