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 5

Text handling: STRING, UNSTRING, INSPECT and text functions interview questions

Interview questions on “Text handling: STRING, UNSTRING, INSPECT and text functions”.

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

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher to mid

    Why does STRING FIRST-NAME DELIMITED BY SPACE " " LAST-NAME DELIMITED BY SPACE drop the space?

    Answered in the lesson STRING, UNSTRING and reference modification

  2. Fresher to mid

    What does NAME(3:4) mean, and what happens when the slice runs past the end of NAME?

    Answered in the lesson STRING, UNSTRING and reference modification

  3. Fresher to mid

    How does INSPECT ... TALLYING FOR ALL differ from FOR LEADING?

    Answered in the lesson INSPECT, TRIM, UPPER-CASE and NUMVAL

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 partner now sends payments as comma-separated lines, which the program splits with UNSTRING DELIMITED BY ",". Since the switch, some payments post to the wrong branch and a few amounts arrive cut short, yet the batch reports no errors. How do you find the bad lines, and what do you change?

    What it tests
    Knowing what UNSTRING does with empty fields, extra delimiters, leading spaces and long values, and using TALLYING IN, COUNT IN and ON OVERFLOW to reject a line instead of posting it.
    First step
    Add the checks UNSTRING already offers and count what fails. In the lesson an empty field became spaces, the last field kept its leading spaces, a count of 15 exposed a value longer than its 9-byte field, and a line with one field too many ran ON OVERFLOW. A value that contains a comma moves every later field along by one.
    Follow-ups

    From the lesson STRING, UNSTRING and reference modification

    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. Fresher to mid

    A statement program builds each detail line with STRING into PRINT-LINE. For some customers the line ends with an extra amount that belongs to the customer printed before them, although no statement moves that amount there. What is happening, and how do you fix and test it?

    What it tests
    Knowing that STRING writes only the positions it fills, clearing a receiver before building it, and testing lines of different lengths in sequence.
    First step
    Compare a wrong line with the line printed just before it. In the lesson, STRING "RAVI" into a field that held ANITA DESAI left RAVIA DESAI: STRING never clears its receiver, so a shorter line keeps the tail of a longer one.
    Follow-ups

    From the lesson STRING, UNSTRING and reference modification

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  3. Mid to senior

    After a move to GnuCOBOL 3.2, an upload of branch amounts posted 12.50 for a line that read 12.5.0, and an old check that rejected bad amounts when NUMVAL returned zero now rejects nothing. What changed, and how do you validate the amounts from now on?

    What it tests
    Knowing that GnuCOBOL 3.2 NUMVAL skips invalid characters instead of returning zero, validating with TEST-NUMVAL or TEST-NUMVAL-C before converting, and testing the rules with malformed input.
    First step
    Read the GnuCOBOL 3.2 NEWS: NUMVAL used to return zero for an argument that breaks its rules, and now skips the invalid data. In the lesson NUMVAL turned 12.5.0 into 12.500, while TEST-NUMVAL returned 5, the position of the second point.
    Follow-ups

    From the lesson INSPECT, TRIM, UPPER-CASE and NUMVAL

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  4. Mid to senior

    An audit finds full account numbers in the job logs of a nightly COBOL batch, written by DISPLAY statements in its error paths. How do you remove them without losing what support staff need, and how do you make sure none come back?

    What it tests
    Masking data before it is displayed, finding every place that logs it, keeping enough for support to find a record, and testing the logs against a pattern.
    First step
    Find every DISPLAY that names the account field or a record that contains it, then mask a copy before it is shown. In the lesson INSPECT ACCT-NO(1:6) REPLACING CHARACTERS BY "*" turned AC00417321 into ******7321.
    Follow-ups

    From the lesson INSPECT, TRIM, UPPER-CASE and NUMVAL

    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.