COBOL, an acronym for Common Business Oriented Language is an English-like computer programming language compiled and designed primarily for business use. Read more about COBOL and get a job in this field, by going through the COBOL interview questions below carefully.
The COBOL language is still being used in applications that are deployed on mainframe computers, like large-scale batch and transaction processing jobs. Being imperative, procedural and object-oriented, COBOL is mainly used by businesses, finance organizations, and administrative systems for enterprises as well as governments.
If you feel that there is a lot of content that you cannot read all at once, then, you can download all the COBOL interview questions as a PDF which shall enable you to get over these questions and answers offline as well.
Here in this article, we will be listing frequently asked COBOL Interview Questions and Answers with the belief that they will be helpful for you to gain higher marks. Also, to let you know that this article has been written under the guidance of industry professionals and covered all the current competencies.
In general, there are five different data types in COBOL, they are:
COBOL uses the Occures clause to define and access an array/table. To access an array/table in COBOL we can use the INDEX or SUBSCRIPT and access all the elements within it as well.
Subscript | Index |
---|---|
Means the number of occurrences of an array | This means the number of displacement positions of an array. |
Always declared in the working-storage section. | It need not be declared inside the working-storage section. |
It is initialized by the MOVE statement | It is initialized by the SET operator. |
It is comparatively slow to access | It is faster than Subscript |
Value is incremented using the ADD operator. | Here, the value is incremented using the MOVE operator |
Not necessary to declare INDEXED BY clauses. | Necessary to declare INDEXED BY and any other clauses in Index. |
Static Linking | Dynamic Linking |
---|---|
Here, all the library modules are basically copied into a final executable image. | This refers to the names of external or shared libraries that are placed on the memory. |
The OS places a single file on the memory containing the source code and other referencing libraries. | This lets programmers use a single copy of the executable file once the program has been loaded, but not the original file, a copy of it. |
Binary Search | Sequential Search |
---|---|
In this, table element key values should be in an ascending or descending order. | In this, table element keys are not required to be in any order. |
The table is “halved” or divided into two sections to search for the matching result. | The table is searched from the top to bottom in a sequence until the matching result is found. |
The better option for large tables, i.e. tables having more than 70 elements. | The better option for small tables, i.e. tables with less than or equal to 70 elements. |
SEARCH ALL syntax is used in Binary Searches | SEARCH syntax is used for sequential searches. |
While applying the SEARCH statement, users must abide by these following rules:
In COBOL, SSRANGE is basically a compiler option which is used to handle the array overflow systematically. In the COBOL programming language, SSRANGE also needs to be specified which helps to find the exact subscript out of range.
Whereas, the NOSSRANGE is used in COBOL for very sensitive performance-based applications. The NOSSRANGE is usually the default option which does not support runtime errors if by any case the index or subscript goes out of range.
In COBOL, the Procedure division is used for including the logic of the program efficiently. Consisting of multiple executable statements using variables that are defined in the data division, this type of division, paragraph and section names are focused to be user-defined.
In the procedure division, there must be at least one statement. The last statement used for ending the execution is either STOP RUN or EXIT PROGRAM.
Here’s an example to demonstrate the procedure division:
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NAME PIC A(30).
01 WS-ID PIC 9(5) VALUE '12345'.
PROCEDURE DIVISION.
A000-FIRST-PARA.
DISPLAY 'Hello There'.
MOVE 'Ankit Satpathy' TO WS-NAME.
DISPLAY "Here is my name : "WS-NAME.
DISPLAY "Here's my ID : "WS-ID.
STOP RUN.
Global Variable | External Variable |
---|---|
It is a type of variable which is available throughout the program. | Also available throughout the program, it is declared but not allocated any memory space. |
It is applicable only when sharing data among nested programs via the ANSI85 dialect. | It is used to access globally declared data, including data declared using EXTERNAL or by other COBOL programs. |
This specifies that a data-name is available for every program being contained within the program that declares it. | Here, any external data item can be referenced via any program inside the run unit describing the data item. |
Here’s the difference in performing a Section and a Paragraph in COBOL
PARAGRAPH | SECTION |
---|---|
It is just a block of code containing one or more sentences. | This is a block of code that contains one or more paragraphs. |
It begins with a paragraph name and ends with the starting of the next paragraph. | It begins with a section name and ends with the starting of another section. |
This can be ended in another way by another section starting or by the end of the program. | It cannot be ended another way. |
All the paragraphs should code in AREA A. | All Sections should also code in AREA A. |
Syntax: Paragraph-name. | Syntax: {Section-name} SECTION. |
A scope terminator is basically any COBOL verb that is always conditional, like, (IF and EVALUATE) or it has a conditional clause such as (COMPUTE, PERFORM, READ) matching scope terminator always. Completed by including the reserved word being terminated, it always starts with END-.
NEXT SENTENCE | CONTINUE |
---|---|
This statement passes the control after the next implicit scope terminator; i.e. period (.) | This passes the control after the next Explicit scope terminator. For example, END-IF, END-PERFORM, etc. |
It gives control to the verb which follows the next period. | This gives control to the next verb after the scope terminator. |
This will focus on the next step after the period no matter the number of controls present. | It will focus on scope terminators and other conditions first before going into other controls. |
First of all, the SOC7 abend error is displayed when there is invalid data inside the comp field and the program is processing some computation on it. To start with, check the data you are passing as input because there must be some corrupt data which is the root cause of this error.
Here are some steps to solve this error: