Quiz — Chapter 11: Sequential File Processing
Multiple Choice
1. What does the ASSIGN TO clause in a SELECT statement specify?
a) The physical record layout of the file b) The logical-to-physical mapping (DD name on z/OS, filename on other platforms) c) The access mode for the file d) The record key for indexed access
2. Which RECORDING MODE indicates variable-length records?
a) F b) V c) U d) S
3. What does BLOCK CONTAINS 0 RECORDS mean?
a) The file has no blocking (one record per block) b) The system chooses the optimal block size c) The block size is zero bytes d) Blocking is disabled for this file
4. Which statement is correct about the WRITE statement?
a) WRITE uses the file name (e.g., WRITE OUTPUT-FILE) b) WRITE uses the record name (e.g., WRITE OUTPUT-RECORD) c) WRITE uses the DD name (e.g., WRITE OUTFILE) d) WRITE uses the status variable name
5. What is the "priming read" pattern?
a) Reading the last record of the file first b) Reading the first record before the processing loop begins c) Reading all records into memory before processing d) Reading every other record
6. What FILE STATUS code indicates disk space exhausted on a WRITE?
a) '10' b) '23' c) '34' d) '48'
7. In a file with multiple 01-level records under one FD, the records:
a) Are stored in separate areas of memory b) Share the same physical buffer (implicit REDEFINES) c) Must be read into different files d) Must all have the same structure
8. The OPTIONAL keyword on a SELECT statement means:
a) The file is read-only b) The file may not exist at OPEN time; if absent, it is treated as empty for INPUT c) The file can be opened in any mode d) File status checking is optional
9. What is a Record Descriptor Word (RDW)?
a) A comment at the beginning of the record b) A 4-byte header on z/OS variable-length records containing the record length c) The FD entry for the record d) The KEY clause for indexed files
10. Which WRITE ADVANCING clause starts a new page?
a) AFTER ADVANCING 0 LINES b) AFTER ADVANCING NEW-PAGE c) AFTER ADVANCING PAGE d) AFTER ADVANCING TOP
11. What does READ ... INTO accomplish that plain READ does not?
a) It reads the record into the FD buffer b) It copies the record to a working-storage area in addition to the FD buffer c) It validates the record automatically d) It reads multiple records at once
12. In a header-detail-trailer file, what are "control totals"?
a) Total number of bytes in the file b) Checksums in the trailer (record count, total amount) used to verify file integrity c) The header record's field values d) Counts of each record type
True/False
13. LINE SEQUENTIAL is part of the COBOL standard and works on all platforms. True / False
14. BLOCK CONTAINS improves I/O performance by combining multiple records into a single physical block. True / False
15. The DEPENDING ON clause for variable-length records is automatically set on READ and used on WRITE. True / False
16. You can WRITE to a file opened for INPUT. True / False
17. Sequential files can only contain one type of record. True / False
18. OPEN EXTEND adds records to the end of an existing file. True / False
Short Answer
19. Explain the difference between OPEN OUTPUT and OPEN EXTEND. When would you use each?
20. A sequential file contains three record types: header (type 'H'), detail (type 'D'), and trailer (type 'T'). Describe the validation checks you would perform to ensure the file structure is correct.
21. Write the SELECT, FD, and WORKING-STORAGE entries needed to define a sequential input file with fixed-length 200-byte records, including FILE STATUS with 88-level conditions for success and EOF.
22. Explain why blocking dramatically improves sequential file I/O performance. If a file has 150-byte records and a block size of 27,000 bytes, how many records fit per block, and approximately how much faster is blocked I/O compared to unblocked?
23. Describe the balanced-line merge algorithm for merging two sorted sequential files. What role does HIGH-VALUES play?
Answer Key
- b — ASSIGN TO maps the logical file to a physical dataset or filename.
- b — V indicates variable-length records.
- b — The system selects the optimal block size for the device.
- b — WRITE uses the record name, not the file name.
- b — The priming read reads the first record before the loop.
- c — '34' indicates disk space exhausted on sequential write.
- b — Multiple 01-levels share the same buffer (implicit REDEFINES).
- b — OPTIONAL files may not exist; treated as empty for input.
- b — RDW is a 4-byte header containing the record length.
- c — AFTER ADVANCING PAGE starts a new page.
- b — READ INTO also copies the record to working storage.
- b — Control totals in the trailer verify file integrity.
- False — LINE SEQUENTIAL is a non-standard extension.
- True — Blocking combines records, reducing physical I/O operations.
- True — The system sets DEPENDING ON after READ and uses it during WRITE.
- False — WRITE requires OUTPUT, I-O, or EXTEND mode (FILE STATUS '48' error).
- False — Sequential files can contain multiple record types.
- True — EXTEND positions at end of file for appending.