COBOL Interview Questions and Answers
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.
Most Frequently Asked COBOL Interview Questions
In general, there are five different data types in COBOL, they are:
- Alphabetic
- Numeric
- Alpha-numeric
- Sign
- Assumed Decimal Point
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:
- This statement can only be applied to a Table only if it has been indexed using the INDEXED BY statement.
- The index must be initialized using the SET operator.
- This statement cannot be used for finding multiple matches.
- The SEARCH statement can be only used for doing a sequential or serial search of the table.
- If the search process reaches the end of an array, automatically the end statement will be executed.
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. |