Chapter 10 Sequential Data Files Exam Prep - Practice Test Bank | Prelude Programming 6e Venit by Stewart Venit. DOCX document preview.
Test Bank for Prelude to Programming Chapter 10
MULTIPLE CHOICE
1. Which of the following is an advantage of batch processing?
a. | data files are usually better for input of large amounts of data |
b. | data files can be used by more than one program |
c. | data files can store the output of a program |
d. | all of the above are advantages of batch processing |
2. Text files are simpler than binary files because:
a. | most operating system files are text files |
b. | virtually every computer system can correctly interpret the contents of a text file without any special software |
c. | text files contain certain symbols and codes in addition to standard characters |
d. | all of the above are reasons why text files are simpler than binary files |
3. Which is not one of the basic steps involved in creating a sequential file?
a. | Open the file |
b. | Create the contents of the file |
c. | Close the file |
d. | All of the above must be done to create a sequential file |
4. How does a program indicate the end of a record in a data file?
a. | with an end-of-file marker |
b. | with an end-of-record marker |
c. | with the EOF function |
d. | when the user stops entering data |
5. Which is the correct way to create a file which will be saved on disk with the name AutoList and will be referred to in the program as cars?
a. | Open “AutoList” For Output As cars |
b. | Open “cars” For Output As AutoList |
c. | Open “AutoList” For Input As cars |
d. | Open “cars” For Input As AutoList |
6. Given: A file with the internal name payfile whose records contain each employee’s ID number and rate of hourly pay. Which of the following will assign the values of one record to the variables named IDNum and Pay?
a. | Read IDNum, Pay, payfile |
b. | Read From payfile Write IDNum, Pay |
c. | Read payfile, IDNum, Pay |
d. | Read payfile, IDNumber, payrate, IDNum, Pay |
7. When a file is opened for Output, all data in that file is:
a. | immediately rewritten to an array |
b. | erased |
c. | appended |
d. | none of the above |
8. How many records are there in a file that contains the following:
“Joe”,96,83<CR>”Ann”,92,76<CR>”Alf”,68,84<CR>
”Moe”,98,89<CR><EOF>
a. | 4 | b. | 12 | c. | 16 | d. | 17 |
9. The following steps are used for which process relating to a sequential file?
1. Open the file for Output
2. Use Read statements to assign data in each record to program variables
3. Use the EOF function to determine the end of the file
4. Close the file
a. | creating a file |
b. | reading the contents of a file |
c. | modifying the contents of a file |
d. | merging two files |
10. What are the contents of the file named legs after the given program segment is executed? Assume the content of the file named Animals originally contains the following:
Animals: “Duck”,2<CR>”Dog”,4<CR>”Octopus”,8<CR><EOF>
pseudocode: Open “Animals” For Input As Creatures
Open “legs” For Output As TempFile
Read Creatures, Name, Number
Write TempFile, Name, Number
Close Creatures, TempFile
a. | “Duck”,2 |
b. | “Duck”,2,<CR> |
c. | “Duck”,2,<CR><EOF> |
d. | “Duc”Duck”,2<CR>”Dog”,4<CR>”Octopus”,8<CR><EOF> |
11. What are the contents of the file named legs after the given program segment is executed? Assume the content of the file named Animals originally contains the following:
Animals: “Duck”,2<CR>”Dog”,4<CR>”Octopus”,8<CR><EOF>
pseudocode: Open “Animals” For Input As Creatures
Open “legs” For Output As TempFile
While NOT EOF(creatures)
Read Creatures, Name, Number
If Name != “Octopus” Then
Write TempFile, Name, Number
End If
End While
Close Creatures, TempFile
a. | “Duck”,2<CR>”Dog”,4<CR> |
b. | “Duck”,2<CR>”Dog”,4<CR><EOF> |
c. | “Octopus”,8,<CR><EOF> |
d. | “Duc”Octopus”,8<CR><EOF> |
12. Which operation cannot be completed with the use of sequential files?
a. | inserting a record in the middle of a file |
b. | deleting a record in the middle of a file |
c. | changing the value of one field in one record in a file |
d. | all of the above are possible |
13. Given the following contents of a sequential file, how many fields are in each record?
“Duck”,”yellow”,”feathers”,2<CR>
“Dog”,”brown”,”fur”,4<CR>
“Fish”,”gold”,”scales”,0<CR><EOF>
a. | 3 | b. | 4 | c. | 5 | d. | 12 |
- Which of the following is not an example of a file with records that contain fields?
a. | an employer keeps a file of her employees including each employee’s name, address, phone number, and ID number |
b. | a school child keeps a file of all the books she has read in one year including the book’s title, author, publisher, and number of pages |
c. | a business keeps a file of the names of its suppliers, a file of the names of its customers, and a file of its major overhead expenses |
d. | all of the above are examples of a sequential file with records that contain fields |
15. Given that you have a file with the internal name Books which contains twenty records, with three fields per record (title, author, publication year), how many passes will be executed in the following loop?
While NOT EOF(Books)
Read Books, Title, Author, Year
End While
a. | 1 | b. | 3 | c. | 20 | d. | 21 |
TRUE/FALSE
1. True/False: Input to a program from a data file is called batch processing.
2. True/False: A file that allows any record to be read independently of the others is known as a direct-access file.
3. True/False: The type of file that consists solely of standard keyboard characters is a binary file.
4. True/False: Text files are easier to create than binary files.
5. True/False: Today most operating system files, program files, and data files that are produced by applications are binary files.
6. True/False: Sequential files are sometimes called rapid-access files.
- True/False: When a sequential file is created, the programmer must give it an internal name which is the name by which it will be known in the program code.
8. True/False: Records in a sequential file are separated by an end-of-record marker.
9. True/False: The EOF (end-of-file) function is the same thing an end-of-record marker.
10. True/False: To delete, change, or insert a record within an existing sequential file, the entire file must be rewritten.
- True/False: It is possible to use an array instead of using a temporary “scratch” file to modify a sequential file.
12. True/False: If two sequential files are merged, one with 12 records and one with 14 records, and no two records are the same, the resulting file will contain 27 records.
13. True/False: A Close statement is not necessary when you create a sequential file.
14. True/False: To Read the contents of a sequential file, you must first Open the file for Input.
15. True/False: Control-break processing uses a control variable to exit a loop or a module when a specific condition is met.
SHORT ANSWER
1. __________ files contain records that must be processed in the order in which they were created.
2. A(n) __________ is a collection of data with a name which is saved on a computer’s storage medium.
- The type of input that is provided by the user while a program is running is __________ input.
- A data file consists of __________ which are groups of related data.
5. One data item in a record is called a(n) __________.
6. A file that has records that can be accessed independently, like the tracks on a CD, is a(n) __________ file.
7. When a sequential file is created, the __________ name is the name that it will be saved with on a computer’s storage medium.
8. The __________ __________ states the purpose for which you want to open a sequential file.
9. To modify a sequential file, a(n) __________ file temporarily stores the contents of the given file while it is being modified.
10. In the technique called __________ __________ __________, a data file is processed until a control variable changes value or reaches a pre-assigned level.
11. In the statement: Open “MyDataFile” For Input As MyFile , the word Input tells us the file __________.
12. To access the eleventh record in a __________ data file, we must read in the first ten records first.
13. A(n) __________ file consists solely of standard keyboard characters.
14. The following steps are used to __________ two sequential files:
Open the existing files for Input
Open the new file for Output
Read the records, comparing those of the first file to the second
Write the records in order to the new file
Close all files
15. The name by which a sequential file is known within the program code is its __________ name.