COBOL Module 1
Start here: COBOL today, its standards, compilers and source format interview questions
Interview questions on “Start here: COBOL today, its standards, compilers and source format”.
Warm-up questions
Short questions with short answers, each answered in full.
-
Fresher to mid
How does the COBOL standard differ from a COBOL dialect?
Answered in the lesson COBOL today: where it runs and which compiler to use
-
Fresher to mid
How do cobc -x and cobc -m differ?
Answered in the lesson Install GnuCOBOL, compile with cobc and run programs
-
Fresher to mid
Which areas make up a fixed-form COBOL line, and what goes in each?
Answered in the lesson Reference format: columns, Areas A and B, free-form
-
Fresher to mid
How does a COBOL sentence differ from a statement?
Answered in the lesson Divisions, paragraphs and the period that ends them
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 COBOL report program you tested with GnuCOBOL on your laptop prints signed amounts differently, and its records come out a different size, once the team compiles it on z/OS. How do you find the cause, and how would you make local testing trustworthy?
- What it tests
- Knowing that output and storage depend on the compiler's dialect, comparing like with like, and keeping the target compiler as the final check.
- First step
- Write down both builds: compiler, version and options. Rebuild locally with -std=ibm and compare the outputs again. In the lesson's program the default dialect printed +042.50 and the ibm dialect 04250+, and a two-digit binary item took 1 byte against 2, which is the size IBM documents.
- Follow-ups
-
- Which differences would you expect -std=ibm to remove, and which not?
- How would you stop the two builds drifting apart again?
- When is a local run good enough to ship a change?
From the lesson COBOL today: where it runs and which compiler to use
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
A manager quotes a page saying that most bank transactions run on COBOL and asks whether your team should start rewriting its COBOL now. How would you check the claim, and what would you measure instead to make the decision?
- What it tests
- Separating a claim from a measurement, and basing a modernisation decision on the team's own code, risk and cost rather than on industry statistics.
- First step
- Ask for the claim's source and look for the original measurement: who counted, what and when. Then set the claim aside and list what decides a rewrite of your own system: the programs you run, how often they change, the defects and incidents they cause, and who can maintain them.
- Follow-ups
-
- What does the Stack Overflow survey's 1 % tell you here, and what not?
- Which numbers about your own programs would you collect first?
- What would make you choose a gradual change over a rewrite?
From the lesson COBOL today: where it runs and which compiler to use
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A shell script runs three COBOL batch steps in a row. Step two meets bad input and prints an error, yet the script runs step three and reports success. What do you check in the program and in the script, and how do you fix both?
- What it tests
- Knowing that RETURN-CODE becomes the exit status, that a script carries on unless it tests the status, and that a shell sees only 8 bits of an exit status.
- First step
- Run step two alone on the bad input and print its status with echo $?. A 0 means the program's error path never sets RETURN-CODE; anything else means the script never tests it. Check the value too: a code of 300 arrived as 44 in the lesson, and 4096 would arrive as 0.
- Follow-ups
-
- How would you make the script stop at the first failing step?
- Which return codes would you choose, and why not 4096?
- How does the same check work in a z/OS job?
From the lesson Install GnuCOBOL, compile with cobc and run programs
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Your team builds its COBOL with a plain cobc -x. Which compiler flags would you add to development and test builds, which to the builds that go to production, and why might the two differ?
- What it tests
- Knowing what -Wall, -debug and -std do, that run-time checks cost time, and that every build must use the same dialect.
- First step
- Separate two jobs: finding mistakes and fixing behaviour. -Wall and -debug find mistakes; -std decides how the program behaves. In the lesson, -Wall printed nothing for a subscript of 4 in a table of 3, and only the -debug build stopped with out of bounds: 4 and exit status 1.
- Follow-ups
-
- Why must -std be the same in every build?
- What do the -debug checks cost, and how would you find out for your programs?
- Which warnings would you turn into errors?
From the lesson Install GnuCOBOL, compile with cobc and run programs
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
After a teammate renamed a data item, a credit-limit calculation began giving smaller limits, yet the program compiles without warnings and the changed lines look correct. What do you suspect, how do you prove it, and how do you stop it happening again?
- What it tests
- Recognising the column-72 margin of fixed form as the cause, proving it from the source and with a test, and adding a check that runs on every build.
- First step
- A rename makes lines longer, so measure every changed line and print what lies after column 72. In the lesson, line 9 ended with 00 in columns 73 and 74, so + 1000000 compiled as + 10000 and the limit came out as 260,000 instead of 1,250,000.
- Follow-ups
-
- Which compiler flags would have caught it, and why not -Wall?
- How would you check a code base whose lines carry tags in columns 73 to 80?
- What test would have caught the wrong limit?
From the lesson Reference format: columns, Areas A and B, free-form
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
Your team wants to move its fixed-form COBOL to free-form source. What would you check before and after converting, and what might make you keep fixed form?
- What it tests
- Knowing what fixed form gives meaning to and free-form reads differently, how to prove a conversion changed nothing, and the limits of target compilers and tools.
- First step
- List what fixed form gives meaning to and free-form does not: the indicator in column 7 (comments, continuations and D lines), tags in columns 73 to 80, and the Area A rules. Then plan the proof: build before and after, run the same tests and compare the outputs byte for byte.
- Follow-ups
-
- How would you convert continued literals?
- How do you prove that the converted programs behave the same?
- What about programs that are also compiled on z/OS?
From the lesson Reference format: columns, Areas A and B, free-form
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Fresher to mid
Customers in credit are being charged an overdraft fee. The fee paragraph has an IF with no END-IF, and its statements end with periods. How do you find the cause, fix it and stop it coming back?
- What it tests
- Knowing that a separator period ends every open statement, reproducing the bug with a test, and the END-IF style that prevents it.
- First step
- Run the paragraph for one account in credit and one overdrawn, and compare the fees with the expected ones: in the lesson, two accounts gave 050.00 instead of 025.00. Then find where the IF really ends: at the first period after it.
- Follow-ups
-
- How would you find every IF in a program that ends at a period?
- What test would have caught the bug?
- Why not just delete the stray period?
From the lesson Divisions, paragraphs and the period that ends them
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
You are asked to remove every NEXT SENTENCE from a legacy program because the compiler reports it as archaic. Can you replace each one with CONTINUE mechanically? How would you make the change safely?
- What it tests
- Knowing that NEXT SENTENCE jumps past the next period while CONTINUE does nothing, and changing control flow only under tests.
- First step
- Not mechanically: the two differ whenever statements follow in the same sentence. In the lesson, NEXT SENTENCE inside IF ... END-IF skipped two DISPLAY statements that CONTINUE would have run. For each one, list the statements between it and the next period.
- Follow-ups
-
- When is the swap safe?
- How do you rewrite a case where it is not safe?
- How do you prove that the program still behaves the same?
From the lesson Divisions, paragraphs and the period that ends them
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes