COBOL Module 6
Tables: OCCURS, SEARCH and SORT interview questions
Interview questions on “Tables: OCCURS, SEARCH and SORT”: warm-ups, then what each harder question tests and how a good answer starts.
Warm-up questions
Short questions with short answers, each answered in full.
-
Fresher to mid
How does a subscript differ from an index in COBOL?
-
Fresher to mid
How many bytes does a two-dimensional table of 2 rows of 3 amounts PIC 9(5)V99 take?
-
Fresher to mid
What must be true of a table before SEARCH ALL can be used on it?
Answered in the lesson SEARCH ALL, table SORT and OCCURS DEPENDING ON
Questions with model answers
What each question tests, the first step of a good answer and the follow-ups to expect.
-
Mid to senior
A program keeps 20 branch codes in a table that it loads from a file. Since the file grew to 23 lines, the run's grand total is wrong, although the code that adds it has not changed and the job ends normally. What happened, how do you prove it, and what do you change?
- What it tests
- Recognising a write past the end of a table, proving it with a run-time check, and fixing the load with a capacity test and a size that fits the data.
- First step
- Look at what is stored right after the table, and at how the load counts its entries. In the lesson, entry 6 of a five-entry table wrote MUMBAI over the next field without an error, and a -debug build stopped at that MOVE with subscript out of bounds.
- Follow-ups
-
- Why did the job end normally?
- How large should the table be now?
- Which tests would have caught it before production?
From the lesson Tables, subscripts and indexes
Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.Opening the model answers with your pass…
Model answers open with any MySmartCoPilot pass.
- Pro pass · 1 week₹79$2.99
- 30 days₹179$5.99
- 1 year₹1,699$45
One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.
Passes can’t be bought right now, so the model answers can’t be opened at the moment. If you have a pass, enter your licence key.
It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).
In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
Production COBOL programs at your site are built without subscript range checks. After two incidents of overwritten storage, someone proposes switching on IBM's SSRANGE, or GnuCOBOL's checks, for every build. How do you decide, and what would you do as well?
- What it tests
- Weighing run-time range checks against their cost, knowing what SSRANGE and GnuCOBOL's checks cover, and combining them with checks in the code and tests.
- First step
- Separate finding faults from preventing them. A checked build stops at the first bad subscript, as the lesson's -debug build did, but IBM documents NOSSRANGE as the default, so the question is where the checks run and what the code itself must test.
- Follow-ups
-
- How would you measure what the checks cost?
- What do the checks not catch?
- What does SSRANGE do when a check fails?
From the lesson Tables, subscripts and indexes
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
After a change that lets operators add new rate slabs, a nightly job charges the default rate to some accounts whose slab is in the rate table. The lookup uses SEARCH ALL, and the slabs are loaded from a file. What do you suspect, how do you confirm it, and how do you make the lookup safe?
- What it tests
- Knowing that SEARCH ALL needs the table in key order and fails silently otherwise, finding the misplaced entries, and fixing the load with a sort or an order check.
- First step
- Check the order of the loaded table: slabs appended at the end of the file break the ascending order of the key. In the lesson, two slabs appended after 179 made SEARCH ALL report 104 and 162 as not found, while 133 was still found.
- Follow-ups
-
- Would you sort in the program, or require a sorted file?
- Why did the job charge the default rate instead of failing?
- How would you test the lookup?
From the lesson SEARCH ALL, table SORT and OCCURS DEPENDING ON
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
An input record carries a count of up to 10 amounts, which the program uses as the counter of an OCCURS DEPENDING ON table. One damaged record arrives with a count of 37, and the output for the records after it is garbled. Explain what happened and how you would harden the program.
- What it tests
- Knowing that the counter sets the length of the record, that a value outside the OCCURS range is undefined, and validating counts where the data enters.
- First step
- Work out what the count does to the record's length. In the lesson a count of 11 for a table of at most 10 gave a 61-byte record for a 56-byte area, and a -debug build said nothing. A count of 37 describes 6 + 37 x 5 = 191 bytes.
- Follow-ups
-
- Which checks would have caught it at run time?
- What should happen to the damaged record?
- Does the IBM dialect change your test plan?
From the lesson SEARCH ALL, table SORT and OCCURS DEPENDING ON
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes