COBOL Interview Questions and Answers

What do you know about COBOL?

COBOL stands for Common Business-Oriented Language, a high-level programming language designed for business applications, developed in 1959 by a group called Conference on Data Systems Language (CODASYL).

COBOL/400 is the standard COBOL adopted by IBM for the AS400 system.

List some features of COBOL

1. COBOL is an easy-to-learn
2. It is a standard language that can be compiled and executed on a variety of computers
3. Handling huge volumes of data. COBOL still handles more than 70% of the world’s business transaction
4. The logical control structures available in COBOL make it easy to read, modify and debug

Name the divisions in a COBOL program.

1. Identification Division
2. Environment Division
3. Data Division
4. Procedure Division

What is the purpose of Identification Division?

Identification Division is used for documentation purpose.

What divisions, sections and paragraphs are mandatory in a COBOL program?

Identification Division and Program-Id paragraph are mandatory in a COBOL program.

How many Sections are there in Data Division?

There are six sections in Data Division:
File Section
Working Storage Section
Local Storage Section
Screen Section
Report Section
Linkage Section

What is a linkage section? and use of it?

It is part of a called program that maps to data items in the calling program’s working storage. The linkage section is used to pass data from one program to another program or to pass data from a procedure to a program.

Where does the FILE-CONTROL paragraph appear?

It appears in the Input-Ouput Section in the Environment Division.

What is LOCAL-STORAGE SECTION?

Local-Storage is allocated each time a program is called and will be deallocated when the program stops via an EXIT PROGRAM, GOBACK, or STOP RUN. It is defined in the DATA DIVISION after the WORKING-STORAGE SECTION.

Where does AREA B in COBOL start from?

Area B starts from 12 to 72 column.

What are the different data types available in COBOL? and how to define them?

Alpha-numeric : PIC X(nn).
Alphabetic : PIC A(nn).
Numeric : PIC 9(nn).

What is the maximum size of a numeric field we can define in COBOL?

The maximum size of a numeric field is PIC 9(18).

What is the difference between PIC 9.99 and PIC9v99?

PIC 9.99 is a four position field that actually contains a decimal point whereas PIC 9v99 is a three position numeric field with assumed decimal position.

What is the difference between performing a SECTION and a PARAGRAPH?

As SECTION consist of PARAGRAPH
SECTION will perform all the paragraphs that are part of the section.
PARAGRAPH will only perform that paragraph.

What is the difference between NEXT SENTENCE & CONTINUE statement?

NEXT SENTENCE transfers control to the next sentence, while CONTINUE is like a null statement and it continues execution

What are the different file OPEN / Opening modes available in Cobol?

1. Input – Opens file in read mode.
2. Output – Opens file in write mode (it deletes existing records in file).
3. Input–Output – Opens file in Read and Write mode.
4. Extend – Opens file to append records in existing file without flushing existing records.

What is the mode in which you will OPEN a file for writing?

To write into a file, the file has to be opened in either OUTPUT or EXTEND mode.

What is the use of EVALUATE statement

Evaluate is like a case statement and can be used to replace nested Ifs. No break is required as the control comes out as soon as a match is found

What is ‘IS NUMERIC’ clause?

IS NUMERIC clause is used to check if any item is numeric or not. It returns TRUE when the item against which it is used contains only numbers (0 to 9). The item can be positive or negative

What is Redefines clause?

Redefines clause is used to allow the same storage allocation to be referenced by different data names.

Can I redefine an X(10) field with a field of X(20)?

Yes, as Redefines causes both fields to start at the same location.

What are 66 and 88 level used for?

Level 66 is used for RENAMES clause and Level 88 is used for condition names.

What is 77 level used for?

It is an elementary level item which cannot be subdivided.

What is the difference between SEARCH and SEARCH ALL?

SEARCH is a serial search, whereas SEARCH ALL is a binary search. A table must be in sorted order before using SEARCH ALL

What is the difference between Call By Content and Call By Reference?

The parameters passed in a Call By Content are protected from modification by the called program. In Call By Reference, parameters can be modified by the called program.

What will happen if you code GO BACK instead of STOP RUN in a stand alone COBOL program?

The program will go in an infinite loop.

How is sign stored in a COMP-3 field?

It is stored in the last nibble.

What is the difference between comp and comp-3?

Comp is a binary usage, while comp-3 indicates packed decimal.

What is a Compute Statement?

Compute statement is used to write arithmetic expressions in COBOL. This is a replacement for Add, Subtract, Multiply, and Divide.

What is binary search?

First, we have to compare the item to be searched with the item at the center.
If it matches, it is good to go with the value else repeat the process with the left half or the right half depending on where the item lies.

What is the difference between a binary search and a sequential search?

In a binary search, the table element key values will be in ascending or descending sequence. The table is ‘halved'(Divided into two) to search for equal to, greater than or less than conditions until the element is found.
In a sequential search, the table is searched from top to bottom, so the elements do not have to be in a specific sequence.
The binary search is much faster for more tables, while sequential Search works well with lesser ones. SEARCH ALL is used for binary search; SEARCH for sequential search.

How arrays can be defined in COBOL?

Arrays can be defined as –
05 Array1 PIC X(9) which occurs 10 times
05 Array2 PIC X(9) which occurs 20 times