Latest COBOL Interview Questions & Answers

Latest COBOL Interview Questions

COBOL Interview Questions

What is COBOL?

Answer

COBOL stands for Common Business-Oriented Language. The US Department of Defense, in a conference, formed CODASYL (Conference on Data Systems Language) to develop a language for meeting business data processing needs which is now known as COBOL.

List some features of COBOL.

Answer

COBOL is a standard language that can be compiled and executed on various machines. It is ideally suited for business-oriented applications as it can handle huge volumes of data. It provides numerous debugging and testing tools. COBOL is a structured language; it has different divisions, so it is easy to debug.

Name the divisions in a COBOL program.

Answer

Identification Division, Environment Division, Data Division, and Procedure Division.

What are the different data types available in COBOL?

Answer

Alpha-numeric (X), Alphabetic (A), and Numeric (9).

What is ‘IS NUMERIC’ clause?

Answer

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 are 66 and 88 level used for?

Answer

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

What is the difference between subscript and index?

Answer

Subscript is the occurrence in an array. Index is the displacement from the beginning of an array.

What is the difference between SEARCH and SEARCH ALL?

Answer

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 performing a SECTION and a PARAGRAPH?

Answer

Performing a SECTION will cause all the paragraphs that are a part of the section to be performed. Performing a PARAGRAPH will cause only a particular paragraph to be performed.

What is a scope terminator?

Answer

Scope terminator is used to mark the end of a verb. Example: IF and END-IF.

What are the file opening modes in COBOL?

Answer

File opening modes in COBOL include: INPUT, OUTPUT, I-O, and EXTEND.

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

Answer

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

What is the difference between CONTINUE and NEXT SENTENCE?

Answer

CONTINUE transfers the control to the next statement after the scope terminator. NEXT SENTENCE transfers the control to the statement after the first period is encountered.

Why we cannot define an Occurs clause at 01 level?

Answer

01 is of the record level. We repeat the fields within a record, not the record itself. So an Occurs clause can not be used at 01 level.

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

Answer

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

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

Answer

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 is a linkage section?

Answer

The linkage section is a part of a called program that ‘links’ or maps to data items in the calling program’s working storage.

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

Answer

The program will go in an infinite loop.

How is sign stored in a COMP-3 field?

Answer

It is stored in the last nibble.

What is the difference between comp and comp-3?

Answer

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

What is the purpose of Identification Division?

Answer

Identification Division is used for documentation purpose.

What is the difference between static call and dynamic call?

Answer

In static call, the called program is a standalone program, it is an executable program. During runtime, we can call it in our called program. As about dynamic call, the called program is not an executable program; it can be executed through the called program only.

What is Redefines clause?

Answer

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

What is the Purpose of Pointer Phrase in STRING command?

Answer

The Purpose of Pointer phrase is to specify the leftmost position within the receiving field where the first transferred character will be stored.

What is 77 level used for?

Answer

It is an elementary level item which cannot be subdivided.

What is binary search?

Answer

Compare the item to be searched with the item at the centre. If it matches fine; else repeat the process with the left half or the right half depending on where the item lies.

What is the use of EVALUATE statement?

Answer

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.

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

Answer

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

What is COMP-1 and COMP-2?

Answer

COMP-1 is single precision floating point that uses 4 bytes. COMP-2 is double precision floating point that uses 8 bytes.

What is the function of Accept Verb?

Answer

Accept Verb is used to get data such as date, time, and day from the operating system or directly from the user. If a program is accepting data from the user, then it needs to be passed through the JCL.

What is a Compute Statement?

Answer

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

How do you define the files referred to in a subroutine program?

Answer

Supply the DD cards in JCL just as you would for files referred to in the main program.

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

Answer

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

Where does AREA B in COBOL start from?

Answer

Area B starts from 12 to 72 column.

Where does the FILE-CONTROL paragraph appear?

Answer

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

What is the difference between Perform With Test After and Perform With Test Before?

Answer

If TEST BEFORE is specified, the condition is tested at the beginning of each repeated execution of the specified PERFORM range. If TEST AFTER is specified, the condition is tested at the end of each repeated execution of the PERFORM range. The range is executed at least once in TEST AFTER.

What is LOCAL-STORAGE SECTION?

Answer

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.

What are the access modes of START statement?

Answer

Access modes are SEQUENTIAL or DYNAMIC for the start statement.

What is the difference between PIC 9.99 and PIC9v99?

Answer

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.

Can a Search be done on a table with or without Index?

Answer

No, the table must be indexed to search on a table.

Why is it necessary to open a file in I-O mode for REWRITE?

Answer

Before REWRITE is performed, the record must be opened and read from the file. Therefore, the file must be opened in I-O mode for rewrite functionality.

What are literals?

Answer

A literal is a data item that consists value by itself. It cannot be referred by a name. They are constant data items.

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

Answer

A Stop run ends the unit of work and returns control to the operating system whereas GOBACK returns control to calling program. So if we code GO BACK instead of Stop Run, it will go in infinite loop.

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

Answer

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

Where does the FILE-CONTROL paragraph appear?

Answer

FILE-CONTROL paragraph appears in the Input-Ouput Section in the Environment Division which provides information of external data sets used in the program.

What is the length of PIC 9.999?

Answer

Length of PIC 9.999 is 5 as ‘.’ takes 1 byte. So total 1 byte for ‘.’ and 4 bytes for 9.

Which cobol verb is used for updating a file?

Answer

Rewrite verb is used to update the records. File should be opened in I-O mode for rewrite operations. It can be used only after a successful Read operation. Rewrite verb overwrites the last record read.

If 123 value is moved to a PP999 PIC clause, then what is edited value taken?

Answer

.00123 edited value will be taken. P is assumed decimal scaling position which is used to specify the location of an assumed decimal point when the point is not within the number that appears in the data item. .PIC PP999 means that numeric data item is of 3 characters and there are 5 positions after the decimal point.

Where can we specify OCCURS clause?

Answer

In array declaration, we can specify occurs clause on Elementary item as well as on Group item also.

How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy?

Answer

9(7) will take 7 bytes and 1 byte for SIGN TRAILING SEPARATE, so total 8 bytes it will take.

 

For more COBOL Interview Questions