Quiz: COBOL Program Structure Deep Dive

Multiple Choice

1. In fixed-format COBOL, column 7 is known as the:

a) Sequence area b) Indicator area c) Area A d) Identification area

2. Which of the following must start in Area A (columns 8–11)?

a) MOVE statements b) 05-level data items c) Paragraph names d) IF statements

3. What character in column 7 indicates a comment line?

a) # b) // c) * d) C

4. The SPECIAL-NAMES paragraph DECIMAL-POINT IS COMMA causes:

a) All commas to be treated as decimal points in the source code b) The period and comma to swap roles in numeric editing pictures c) The program to crash if a period appears in numeric data d) Only DISPLAY output to use comma as decimal separator

5. Level 88 data items are used for:

a) Redefining data areas b) Naming conditions associated with specific values c) Defining independent elementary items d) Declaring file descriptions

6. How many periods should appear within a paragraph in modern COBOL best practice?

a) One after each statement b) One after each sentence c) One at the end of the paragraph only d) None — scope terminators replace all periods

7. The COPY statement with REPLACING is used to:

a) Replace a copybook with a newer version b) Substitute text in the copied source during compilation c) Copy a program and rename it d) Replace variables at runtime

8. What is the maximum number of characters in a COBOL PROGRAM-ID?

a) 8 b) 10 c) 30 d) 72

9. LOCAL-STORAGE differs from WORKING-STORAGE in that LOCAL-STORAGE:

a) Uses different PICTURE clause syntax b) Can only hold numeric data c) Is reinitialized each time the program is invoked d) Is accessible from other programs

10. In the FILE-CONTROL paragraph, the FILE STATUS clause:

a) Is optional but strongly recommended b) Is required by the COBOL standard c) Only works with indexed files d) Automatically displays error messages

11. When multiple 01-level records are defined under a single FD, they represent:

a) Multiple records stored simultaneously b) Different physical files c) Different views of the same physical record area d) An error that the compiler will reject

12. The FILLER keyword is used for:

a) Padding numeric fields with zeros b) Unnamed data items that occupy space but are not referenced c) Filling tables with initial values d) Marking unused paragraphs

13. Which paragraph in the ENVIRONMENT DIVISION lets you define custom character classes?

a) FILE-CONTROL b) OBJECT-COMPUTER c) SPECIAL-NAMES d) SOURCE-COMPUTER

14. The D character in column 7 creates a:

a) Documentation line b) Delete marker c) Debugging line compiled only with WITH DEBUGGING MODE d) Directive to the preprocessor

15. In GlobalBank's coding standards, the prefix WS- indicates that a data item is in:

a) The FILE SECTION b) The WORKING-STORAGE SECTION c) The LINKAGE SECTION d) The LOCAL-STORAGE SECTION

Short Answer

16. Explain the "period problem" in pre-COBOL-85 programs and how scope terminators solve it.

17. Why does GlobalBank's coding standard say "one period per paragraph, at the end"?

18. Describe three benefits of using copybooks in a large COBOL system.

19. What is the purpose of the IS INITIAL clause on PROGRAM-ID, and why is it important in CICS programming?

20. Draw or describe the data hierarchy for the following WORKING-STORAGE definition, showing parent-child relationships:

       01  WS-EMPLOYEE.
           05  WS-EMP-ID      PIC X(8).
           05  WS-EMP-NAME.
               10  WS-FIRST   PIC X(20).
               10  WS-LAST    PIC X(25).
           05  WS-EMP-SALARY  PIC S9(7)V99.
           05  WS-EMP-TYPE    PIC X.
               88  EMP-FULL-TIME  VALUE "F".
               88  EMP-PART-TIME  VALUE "P".
               88  EMP-CONTRACT   VALUE "C".

Answer Key

  1. b) Indicator area
  2. c) Paragraph names
  3. c) *
  4. b) The period and comma swap roles in numeric editing pictures
  5. b) Naming conditions associated with specific values
  6. c) One at the end of the paragraph only
  7. b) Substitute text in the copied source during compilation
  8. c) 30
  9. c) Is reinitialized each time the program is invoked
  10. a) Is optional but strongly recommended
  11. c) Different views of the same physical record area
  12. b) Unnamed data items that occupy space but are not referenced
  13. c) SPECIAL-NAMES
  14. c) Debugging line compiled only with WITH DEBUGGING MODE
  15. b) The WORKING-STORAGE SECTION
  16. In pre-COBOL-85 code, the period was the only way to terminate the scope of conditional statements like IF. A misplaced period could silently end an IF block, causing subsequent statements to execute unconditionally. Scope terminators (END-IF, END-PERFORM, etc.) in COBOL-85 provide explicit scope termination, making the period unnecessary for scope control and eliminating this class of bugs.
  17. The single-period-per-paragraph rule eliminates the possibility of accidentally terminating scope within the paragraph. All scope control is handled by explicit scope terminators, and the only period is the one that terminates the paragraph itself. This makes the code safer and easier to maintain.
  18. (1) Consistency: All programs use the identical record layout, eliminating discrepancies. (2) Maintainability: A change to a record layout is made once in the copybook and propagated to all programs on recompilation. (3) Productivity: Developers do not need to retype or reverse-engineer record definitions for each new program.
  19. IS INITIAL causes the program's WORKING-STORAGE to be reinitialized to its VALUE clauses each time the program is called. In CICS, where a single load module may serve many transactions, this ensures each transaction starts with clean data rather than inheriting data from a previous transaction — preventing intermittent, hard-to-diagnose bugs.
  20. Hierarchy:
    • WS-EMPLOYEE (01, group)
    • WS-EMP-ID (05, elementary, PIC X(8))
    • WS-EMP-NAME (05, group)
      • WS-FIRST (10, elementary, PIC X(20))
      • WS-LAST (10, elementary, PIC X(25))
    • WS-EMP-SALARY (05, elementary, PIC S9(7)V99)
    • WS-EMP-TYPE (05, elementary, PIC X)
      • EMP-FULL-TIME (88, condition, VALUE "F")
      • EMP-PART-TIME (88, condition, VALUE "P")
      • EMP-CONTRACT (88, condition, VALUE "C")