Preview (3 of 9 pages)

Preview Extract

Chapter 7: File Handling and Applications
TRUE/FALSE
1. Images and music are contained in binary files.
Answer: True
2. When you copy data from RAM into a file on a storage device, you read to the file.
Answer: False
3. The keyboard and printer are the default input and output devices.
Answer: False
4. Programmers usually use the word “write” to mean “produce hard copy output.”
Answer: False
5. To write a program that produces a report of employees by department number, the records
must be grouped by department number before you begin processing.
Answer: True
6. You can easily merge files even if each file contains a different record layout.
Answer: False
7. You can merge more than two files.
Answer: True
8. You update the transaction file with data from the master file.
Answer: False
9. The terms “parent” and “child” can refer to file backup generations, but they are also used
for a different purpose in object-oriented programming.
Answer: True
10. Files in which records must be accessed immediately are sometimes called instant access
files.
Answer: True
MULTIPLE CHOICE
1. A ____ is a collection of data stored on a nonvolatile device in a computer system.
a. computer message
b. computer interface
c. computer file
d. computer selector

Answer: C
2. When you write a program that stores a value in a variable, you are using ____ storage.
a. permanent
b. temporary
c. resilient
d. resident
Answer: B
3. ____ storage is not lost when a computer loses power.
a. Temporary
b. Intermediate
c. Permanent
d. Variable
Answer: C
4. Files exist on ____ storage devices, such as hard disks, DVDs, USB drives, and reels of
magnetic tape.
a. permanent
b. transient
c. scalable
d. optical
Answer: A
5. The combination of the disk drive plus the complete hierarchy of directories in which a file
resides is its ____.
a. pointer
b. path
c. locator
d. stream
Answer: B
6. Directories and ____ are organization units on storage devices.
a. folders
b. files
c. partitions

d. streams
Answer: A
7. ____ is the more general term for an entity that organizes files.
a. Folder
b. Path
c. Structure
d. Directory
Answer: D
8. ____ are groups of fields that go together for some logical reason.
a. Tables
b. Databases
c. Columns
d. Records
Answer: D
9. Characters are made up of smaller elements called ____.
a. fields
b. records
c. bits
d. bytes
Answer: C
10. A database holds groups of files or ____ that together serve the information needs of an
organization.
a. fields
b. records
c. control breaks
d. tables
Answer: D
11. In most programming languages, before an application can use a data file, it must ____.
a. open the file
b. close the file
c. read the file

d. prepare the file
Answer: A
12. When you copy data from a file on a storage device into RAM, you ____ from the file.
a. delete
b. upload
c. output
d. read
Answer: D
13. When you ____ a file, it is no longer available to your application.
a. examine
b. rewrite
c. close
d. index
Answer: C
14. A ____ is a copy that is kept in case values need to be restored to their original state.
a. read-only file
b. backup file
c. primary file
d. secondary file
Answer: B
15. A ____ is a file in which records are stored one after another in some order.
a. random access file
b. serial file
c. retired file
d. sequential file
Answer: D
16. A ____ is a temporary detour in the logic of a program.
a. sequence break
b. control break
c. control sequence

d. break control
Answer: B
17. To generate a control break report, your input records must be organized in ____ order
based on the field that will cause the breaks.
a. random
b. ascending
c. sequential
d. repeatable
Answer: C
18. A ____ break is a break in the logic of the program that is based on the value of a single
variable.
a. multiple-level control
b. simple control
c. serial control
d. single-level control
Answer: D
19. ____ files involves combining two or more files while maintaining the sequential order.
a. Merging
b. Sorting
c. Splitting
d. Dividing
Answer: A
20. When the records in a file are sorted in order from lowest to highest values, the records
are in ____ order.
a. descending
b. bubble
c. ascending
d. merged
Answer: C
21. The ____ file holds temporary data that is used to update the master file.
a. directory

b. transaction
c. merge
d. database
Answer: B
22. The saved version of a master file is the ____ file; the updated version is the child file.
a. peer
b. subordinate
c. parent
d. child
Answer: C
23. ____ is processing that involves performing the same tasks with many records, one after
the other.
a. Volume processing
b. Batch processing
c. Online processing
d. Standard processing
Answer: B
24. ____ applications require that a record be accessed immediately while a client is waiting.
a. Real-time
b. Batch
c. Database
d. Sort
Answer: A
25. Because they enable you to locate a particular record directly (without reading all of the
preceding records), random access files are also called ____ files.
a. direct access
b. indirect access
c. sequential access
d. temporary access
Answer: A
COMPLETION

1. A(n) ____________________ is a small unit of storage that, for example, holds only one
character in a simple text file.
Answer: byte
2. When businesses store data items on computer systems, they are often stored in a
framework called the data ____________________ that describes the relationships between
data components.
Answer: hierarchy
3. When you store data in a computer file on a persistent storage device, you
____________________ to the file.
Answer: write
4. A(n) ____________________ file holds more temporary data than a master file.
Answer: transaction
5. A program in which the user makes direct requests is a(n) ____________________
program.
Answer: interactive
MATCHING
Match each term with a statement below.
1. Is not lost when a computer loses power a. files
2. Is lost when the program ends or the computer loses power b. kilobytes
3. Thousands of bytes c. characters
4. Millions of bytes d. random access file
5. Billions of bytes e. master file
6. Letters, numbers, and special symbols, such as “A”, “7”, and “$” f. megabytes
7. Single useful data items that are composed of one or more characters g. volatile storage
8. Groups of related records h. fields
9. Holds complete and relatively permanent data i. gigabytes
10. A file in which records can be located in any order j. nonvolatile storage
1. Answer: J
2. Answer: G
3. Answer: B
4. Answer: F
5. Answer: I

6. Answer: C
7. Answer: H
8. Answer: A
9. Answer: E
10. Answer: D
SHORT ANSWER
1. Define and give examples of text files and binary files.
Answer: Text files contain data that can be read in a text editor because the data has been
encoded using a scheme such as ASCII or Unicode. Text files might include facts and figures
used by business programs, such as a payroll file that contains employee numbers, names,
and salaries.
Binary files contain data that has not been encoded as text. Examples include images and
music.
2. List and describe three characteristics that all files have in common.
Answer: Each file has a name. The name often includes a dot and a file extension that
describes the type of file. For example, .txt is a plain text file, .dat is a data file, and .jpg is an
image file in Joint Photographic Experts Group format.
Each file has a specific time of creation and a time it was last modified.
Each file occupies space on a section of a storage device; that is, each file has a size. Sizes
are measured in bytes.
3. What is a database?
Answer: A database holds groups of files, often called tables, that together serve the
information needs of an organization. Database software establishes and maintains
relationships between fields in these tables, so that users can pull related data items together
in a format that allows businesspeople to make managerial decisions efficiently.
4. What happens when you fail to close an output file?
Answer: If you fail to close an output file (a file to which you are writing data), the data
might become inaccessible. You should always close every file you open, and you should
close the file as soon as you no longer need it. When you leave a file open for no reason, you
use computer resources, and your computer’s performance suffers. Also, particularly within a
network, another program might be waiting to use the file.
5. How are the keyboard and monitor used in most programming languages?
Answer: In most programming languages, if you read data from a keyboard or write it to the
display monitor, you do not need to open the device. The keyboard and monitor are the
default input and output devices, respectively.
6. Explain the difference in how programmers use the words print, write, and display.

Answer: Logically, the verbs print, write, and display mean the same thing—all produce
output. However, in conversation, programmers usually reserve the word print for situations
in which they mean produce hard copy output. Programmers are more likely to use write
when talking about sending records to a data file, and display when sending records to a
monitor. In some programming languages, there is no difference in the verb you use for
output, no matter what type of hardware you use; you simply assign different output devices
(such as printers, monitors, and disk drives) as needed to programmer-named objects that
represent them.
7. When might programmers use a control break program?
Answer: In particular, programmers use a control break program when a change in the value
of a variable initiates special actions or causes special or unusual processing to occur. You
usually write control break programs to organize output for programs that handle data records
organized logically in groups based on the value in a field. As you read records, you examine
the same field in each record; and when you encounter a record that contains a different value
from the ones that preceded it, you perform a special action. For example, you might generate
a report that lists all company clients in order by state of residence, with a count of clients
after each state’s client list.
8. How do you merge two alphabetically ordered input files into a new output file when you
wish the output file to be in alphabetical order?
Answer: Because the two input files contain records stored in alphabetical order, and you
want the new file to store records in alphabetical order, you first output the input record that
has the lower alphabetical value in the name field.
The merging method then proceeds like this: compare two records, write the record with the
lower alphabetical name, and read another record from the same input file.
9. Describe what is required to merge more than two files.
Answer: You can merge any number of files. To merge more than two files, the logic is only
slightly more complicated; you must compare the key fields from all the files before deciding
which file is the next candidate for output.
10. What does the term batch processing mean?
Answer: Besides indicating a system that works with many records, the term batch processing
can also be used to mean a system in which you issue many operating-system commands as a
group.

Test Bank for Programming Logic and Design
Joyce Farrell
9781111969752, 9788131525906, 9781111825959

Document Details

Related Documents

Close

Send listing report

highlight_off

You already reported this listing

The report is private and won't be shared with the owner

rotate_right
Close
rotate_right
Close

Send Message

image
Close

My favorites

image
Close

Application Form

image
Notifications visibility rotate_right Clear all Close close
image
image
arrow_left
arrow_right