Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

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.

7 questions: 3 warm-ups and 4 with model answers · Levels: Fresher to staff

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher to mid

    How does a subscript differ from an index in COBOL?

    Answered in the lesson Tables, subscripts and indexes

  2. Fresher to mid

    How many bytes does a two-dimensional table of 2 rows of 3 amounts PIC 9(5)V99 take?

    Answered in the lesson Tables, subscripts and indexes

  3. 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.

  1. 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

    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.

    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
  2. 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

    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
  3. 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

    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
  4. 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

    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

All COBOL interview questions · The COBOL track

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.