COBOL Module 9
EBCDIC, record layouts, Unicode and JSON interview questions
Interview questions on EBCDIC, record layouts, Unicode and JSON: 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
Why does the same text have different bytes on z/OS and on a laptop?
Answered in the lesson EBCDIC, code pages and collating order
-
Fresher to mid
How do you work out a record's length and each field's offset from a copybook?
Answered in the lesson Copybook layouts and converting mainframe extracts
-
Fresher to mid
Why can a PIC X(30) field not hold a 30-character name in Devanagari?
Answered in the lesson UTF-8, national data and names in Indian scripts
-
Fresher to mid
What do the NAME and SUPPRESS phrases of JSON GENERATE do?
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 nightly job copies a file of customer codes, sorted on z/OS, to a Linux server, where a GnuCOBOL program checks that the codes ascend. It stops at the first code that starts with a digit. The file is not damaged. What is happening, and what are your options?
- What it tests
- Knowing the EBCDIC and ASCII collating orders, seeing that a file's order belongs to the system that sorted it, and choosing between sorting again and comparing in EBCDIC order.
- First step
- Look at the two codes on either side of the error. A code that starts with a letter followed by one that starts with a digit is in order in EBCDIC, where letters come before digits, and out of order in ASCII, where digits come first: the lesson's A001 and 1001 compared both ways.
- Follow-ups
-
- How do you make the GnuCOBOL check compare in EBCDIC order?
- When is sorting again on arrival the better fix?
- What else in the program compares strings and may change?
From the lesson EBCDIC, code pages and collating order
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
-
Fresher to mid
After a new transfer job moved an account extract from z/OS to a server, the account numbers and names look right, but many balances are wrong and some negative amounts arrived positive. Nothing failed. What do you suspect, and how do you fix and prove it?
- What it tests
- Telling text from packed, binary and zoned fields, knowing what a text-mode transfer does to each, and proving a conversion with totals.
- First step
- Compare the bytes of one record on both sides with a hex dump. If the text fields match after translation but a packed balance such as X'01234C' arrived as X'01833C', as in the lesson, the transfer translated every byte as a character.
- Follow-ups
-
- Why did some negative amounts become positive?
- What should the transfer and the converter do instead?
- How do you prove that the converted file is right?
From the lesson EBCDIC, code pages and collating order
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A converter on a Linux server reads a z/OS extract with the right copybook, yet every field after the fourth comes out as garbage while the first four are right. The copybook has two PIC S9(2) COMP fields. What do you check, and how do you fix it for good?
- What it tests
- Computing offsets, knowing that binary sizes depend on the compiler's dialect, and adding a length check that fails on the first record.
- First step
- Print the offset and length of each field as the converter's compiler lays them out, and compare with the sizes z/OS uses: in the lesson, GnuCOBOL's default dialect gave PIC S9(2) COMP 1 byte where z/OS gives 2, which moved every later field by one byte.
- Follow-ups
-
- Why were the first fields right?
- How could the converter have caught it on its first record?
- What else can differ between the two dialects?
From the lesson Copybook layouts and converting mainframe extracts
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A new COBOL converter writes every negative zoned amount of an EBCDIC extract as a positive number, while the packed balances and all text fields are right. What could cause it, and how do you find the step that loses the sign?
- What it tests
- Knowing where a zoned field keeps its sign, how translation and sign conventions interact, and finding a defect by looking at the bytes after each step.
- First step
- Take one negative amount and print its bytes in hexadecimal after each step of the converter. The zone of the last byte, D on z/OS, carries the sign, so look for the first step after which that byte, or the character that stands for it, no longer means negative.
- Follow-ups
-
- Which compile options matter here?
- Why did no check report the problem?
- How do you test the fix?
From the lesson Copybook layouts and converting mainframe extracts
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
You must prove that a converted extract of two million account records matches the data on z/OS before it is loaded into a new system. What evidence do you produce, and what does each piece prove?
- What it tests
- Designing a reconciliation from independent checks on both sides, handling rejects, and knowing what each check cannot catch.
- First step
- List what can go wrong, records lost or added, fields decoded wrongly, signs flipped, then choose for each a check computed independently on both sides, starting with the trailer's record count and balance total.
- Follow-ups
-
- What do matching totals not prove?
- How independent must a second decoder be?
- What happens to rejected records?
From the lesson Copybook layouts and converting mainframe extracts
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
-
Mid to senior
Customer names in Hindi and Tamil arrive from a web form in UTF-8. After a nightly COBOL job copies them into PIC X(40) fields, the next system rejects some records for invalid characters. What happened, and how do you fix and prove it?
- What it tests
- Knowing that MOVE cuts bytes, that a split character makes a field invalid UTF-8, and cutting and checking fields on character boundaries.
- First step
- Take a rejected record and look at the last bytes of its name field in hexadecimal. A field that ends with a byte that starts a character, such as E0, without the bytes that complete it, was cut in the middle of a character by a MOVE into a field that was too short.
- Follow-ups
-
- How do you cut a name without splitting a character?
- How do you find the damaged records already sent?
- Which test would have caught it?
From the lesson UTF-8, national data and names in Indian scripts
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Fresher to mid
A new interface must carry customer names of up to 40 characters in any Indian script, or in Latin letters. How many bytes do you give the field in a GnuCOBOL program that keeps UTF-8 in PIC X, and what else goes into the interface description?
- What it tests
- Sizing a UTF-8 field from the bytes a character can take, and stating the encoding and the limits at a boundary.
- First step
- Work out how many UTF-8 bytes one character of each script can take, then settle whether the limit of 40 counts what a reader sees or Unicode code points, because a vowel sign or a virama is a code point of its own.
- Follow-ups
-
- Why not use national data instead?
- What happens to a name longer than the limit?
- Which normal form will the field carry?
From the lesson UTF-8, national data and names in Indian scripts
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
A bank plans to store names in Indian scripts in a z/OS COBOL application whose unit tests run with GnuCOBOL on developers' computers. Would you use national data, UTF-8 items or PIC X fields, and why?
- What it tests
- Comparing the Unicode support of Enterprise COBOL 6.5 and GnuCOBOL 3.2, and keeping one source that both compilers build and test.
- First step
- List what each compiler supports: Enterprise COBOL 6.5 has national data in UTF-16 and UTF-8 items with PICTURE U, while GnuCOBOL 3.2's NEWS lists only parsing support for USAGE UTF-8. Then list what the tests must exercise on the developers' computers.
- Follow-ups
-
- What do you give up by testing with GnuCOBOL?
- Where do the conversions happen?
- How do you size the fields?
From the lesson UTF-8, national data and names in Indian scripts
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
-
Mid to senior
A batch program that reads partner records as JSON was moved to GnuCOBOL 3.2 for testing. It runs to the end with return code 0, yet every record it writes is empty. What do you check first, and how do you make sure it cannot happen again?
- What it tests
- Knowing that a compiler may accept a statement it does not implement, reading its warnings, and making the build and the tests fail on them.
- First step
- Read the compiler's warnings for the program, not only its exit status, then print JSON-CODE and one parsed field right after the first JSON PARSE, so you see whether the statement did anything at all.
- Follow-ups
-
- Why did the run end with return code 0?
- Which build setting stops it?
- How would you test the parsing on both compilers?
From the lesson JSON and XML: GENERATE and PARSE
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Fresher to mid
A service rejects some JSON documents that a COBOL program sends: the ones whose customer names contain quotes. The program builds each document with STRING. What is wrong, what is the risk beyond rejected messages, and how do you fix it?
- What it tests
- Knowing why values in a document must be escaped, the risk of building documents by joining strings, and generating documents instead.
- First step
- Parse one rejected document with a JSON validator and look at the character where the parser stops, next to the customer name it came from.
- Follow-ups
-
- What else could a crafted name do to the document?
- Why does JSON GENERATE not have the problem?
- How do you test the fix?
From the lesson JSON and XML: GENERATE and PARSE
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A program's JSON GENERATE fails on a few records every night with JSON-CODE 1, although the team doubled the receiver last month. How do you size the receiver properly, and what must the program do when generation fails?
- What it tests
- Working out the largest document a record can produce, knowing what a failed statement leaves behind, and handling the failure.
- First step
- Work out the longest document the record can produce, with every field at its full length and every name and punctuation character counted, and compare it with the receiver's size.
- Follow-ups
-
- What do the receiver and COUNT hold after JSON-CODE 1?
- Which characters make a document longer than its fields?
- Where should a failed record go?
From the lesson JSON and XML: GENERATE and PARSE
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes