Quiz — Chapter 4: Data Description Mastery
Multiple Choice
1. What is the storage size of PIC S9(7)V99 COMP-3?
a) 9 bytes b) 7 bytes c) 5 bytes d) 4 bytes
2. Which USAGE type is most appropriate for a field storing an account balance of up to $999,999,999.99?
a) COMP (BINARY) b) COMP-1 c) COMP-2 d) COMP-3
3. What does the V in PIC 9(5)V99 represent?
a) A physical decimal point stored in the data b) An implied decimal point tracked by the compiler c) A validation marker for numeric data d) A variable-length indicator
4. Which level number is used for condition names?
a) 66 b) 77 c) 88 d) 99
5. What happens when you execute MOVE SPACES TO group-item where the group item contains a COMP-3 field?
a) The COMP-3 field is set to zero b) The COMP-3 field is set to spaces (corrupted) c) The compiler rejects this statement d) Only alphanumeric subordinate items receive spaces
6. In the declaration PIC $$,$$$, MATH1 MATH2 $,$$$,$$9.99 — edited numeric for display.
23. (1) Storage: COMP stores as binary (2/4/8 bytes); COMP-3 stores as packed decimal (2 digits/byte). (2) Arithmetic: COMP requires decimal-to-binary conversion for DISPLAY; COMP-3 provides exact decimal arithmetic. (3) Use cases: COMP for subscripts/counters/APIs; COMP-3 for financial/monetary calculations.
24. The variant record pattern uses a type discriminator field followed by a detail area with multiple REDEFINES providing type-specific views. Checking the discriminator is essential because COBOL has no runtime type-checking for REDEFINES — accessing a medical REDEFINES when the record is actually a pharmacy claim reads the same bytes with the wrong interpretation, producing garbage data.
25. TR-NAME: 30 bytes + TR-AMOUNT: 6 bytes (S9(9)V99 = 11 digits + 1 sign nibble = 6) + TR-COUNT: 2 bytes (PIC 9(4) COMP = halfword) + TR-RATE: 3 bytes (5 digits + 1 = 3) + TR-FLAGS: 5 bytes + TR-MONTHLY: 5 bytes × 12 = 60 bytes. Total = 30 + 6 + 2 + 3 + 5 + 60 = 106 bytes.