A COBOL skills interview poses daunting questions to job seekers.
Job seekers for intermediate-level COBOL positions need solid knowledge of and experience with divisions, data types, perform statements and search types. Ease the experience by anticipating what COBOL questions interviewers will ask and practicing a thorough response.
Common COBOL interview questions
1. What sections does the Data Division cover?
The Data Division defines and outlines fields, records and files in storage. It defines all data in a COBOL program.
The Data Division covers six sections: file, working storage, linkage, local storage, report and screen.
The file section contains one or more File Description entries, which consist of level-01 record descriptions. If an entry indicates all records vary in length, you can read the records with the OCCURS DEPENDING ON clause. This causes the records to vary in size depending on the number of occurrences in the record.
Working storage defines the data names so that the program can manipulate the data. This section describes data with the OCCURS clause.
The linkage section is part of a called program that links to data items in the calling program's working-storage section.
A local storage section is allocated each time a program is called. It is deallocated when the program executes EXIT PROGRAM, GOBACK or STOP RUN statements.
The report section contains one or more Report Description entries, which is fairly self-explanatory.
The screen section is used to create forms on a screen.
2. What are search techniques, and when is each best used?
Search is either binary or sequential.
Binary search is faster when there are over 100 entries in the table. Use the binary search when the table entries are in either ascending or descending order. For proper function, use the SEARCH ALL statement with the ASCENDING or DESCENDING key clause. Include the INDEXED BY clause.
Sequential search organizes the table when its entries are in a random order. The SEARCH statement searches the table from top to bottom. You must set the index to 1 for the INDEXED BY clause.
3. How does multithreading differ from single CPU threading?
Multithreading allows a program to run separate tasks -- threads -- simultaneously.
A program runs faster when multiple threads execute on multiple CPUs. To spread a program into multiple threads, use the RECURSIVE clause in the PROGRAM-ID. All COBOL programs must be compiled with the THREAD compiler option to ensure the threads are appropriately allocated.
Speak fluently in multithreading
To work with COBOL in a multithreaded environment, replace the ALTER statement with the EVALUATE statement and the GO TO statement with a procedure name (the PERFORM PARA-1 THRU PARA-2 statement works better).
The PERFORM statement allows you to specify how many times the statement can be repeated, and what happens when conditions are met or not met.
The GOBACK statement replaces the STOP RUN statement to indicate the logical end of a called program.
Each thread can use the same copy of data from the working storage section. If you use the linkage section, ensure that a copy of the local storage section is available for each call of the program. You must release the local storage section when the called program is returned to the main program.
There are some limitations on COBOL multithreading. Avoid unwanted language elements for example; ALTER, GO TO and STOP RUN statements don't work with multithreading.
4. Give some examples of COBOL dialects.
A COBOL dialect contains statements and/or compiler directives unique to that instance of the language. COBOL dialects cannot be used in other dialects.
The Micro Focus Studio Enterprise Edition for Unix contains dialects that are enabled during compilation. For example, with Micro Focus, the ACU dialect enables compatibility with ACUCOBOL. ENTCOBOL specifies that the words reserved in IBM Enterprise COBOL for z/OS and OS/390 are to be treated as reserved words in Micro Focus. ISO 2002 specifies that words reserved in the ISO2002 COBOL Standard are to be reserved in Micro Focus. In this standard, areas A and B reference format are combined into the program text area -- the text can begin anywhere in that area.
5. What is the biggest issue to consider when the main COBOL program calls a C/C++ subprogram?
The biggest issue is the memory overflow in a C/C++ subprogram called by the main COBOL program during compilation. When too much memory is used, stack overflow happens and is exacerbated when the stack size of a given C/C++ subprogram is reduced. The program has less stack space per thread when running the subprogram in multithreading modes. The less the stack space, the more likely memory will overflow.
The problem is made worse when threads share the heap. Ensure the threads don't try to access the same pieces of memory at the same time in the C program.
Hopefully these interview questions and answers will help you land that COBOL job.
System administrator interview questions
Five questions to land a Windows admin job
Ace a cloud administrator interview