Top 50+ Most Asked COBOL Interview Questions and Answers

Following is a list of most frequently asked COBOL interview questions and answers.

1) What is COBOL? / What do you know about COBOL?

COBOL is an abbreviation that stands for Common Business Oriented Language. It is one of the oldest programming languages and is primarily used for business verticals, including government companies' functions, finance, and administrative systems. It is a weak, static typing discipline language. COBOL programming language is mainly used for large-scale batch and transaction processing jobs and solving complex business problems.


2) Is COBOL an outdated programming language? Is it still used? / Is it still worth learning COBOL programming language nowadays?

It is a fact that COBOL is one of the oldest programming languages, but you cannot say that it is an outdated programming language. It is still used, and yes, it is still worth learning. It is up to the users or programmers who want to maintain them or port them to other programming languages.

COBOL facilitates a lot of things to do easily. It is a more than 60 years old programming language, but recently, there is a rise in demand for this language due to the requirements of some government agencies and projects. Nowadays, COBOL is used in many government projects, and programmers use it in many state government operations.


3) How was the COBOL programming language developed? / What is the history of the COBOL programming language?

In 1959, the USA Government's Department of Defense formed CODASYL, an acronym for Conference on Data Systems Language. The main motive behind forming the CODASYL was to develop a computer programming language known as COBOL. The main purpose of this language was to meet business, administrative, finance needs. It is a simple language that works on easy English terms and phrases so that business users understand it easily and fulfil their data processing needs through COBOL.


4) What are the different data types that COBOL supports?

There are mainly three data types that COBOL supports:

  • Alpha-numeric (X): The alpha-numeric data type can hold both values together, either alphabetic or numeric.
  • Alphabetic (A): The alphabetic data type of COBOL programming language can hold any of the alphabetic variables ranging between A-Z.
  • Numeric (9): The numeric data type represents numeric values between 0-9 in COBOL programming.

5) What is the difference between subscript and index in COBOL?

The main difference between subscript and index is that the subscript is called the occurrence of an array. On the other hand, index refers to the displacement from the beginning of the array. An index can only be modified using PERFORM, SEARCH & SET.


6) What are some distinctive features of COBOL?

Following is a list of some key features of COBOL:

  • COBOL is a standard programming language that can be compiled and executed on various machines.
  • COBOL programming language is best suited for business-oriented applications as it can handle huge volumes of data.
  • COBOL provides several debugging and testing tools.
  • COBOL is a structured language that has different divisions, so debugging is easy in COBOL.

7) What are the different divisions used in a COBOL program?

Different divisions used in a COBOL program are:

  • Identification Division
  • Environment Division
  • Data Division
  • Procedure Division

8) What is the difference between a section and a paragraph in the COBOL programming language?

In the COBOL programming language, a section consists of all the paragraphs that are part of the section and must be performed. On the other hand, a paragraph consists of only that paragraph that has to be performed.


9) What is the 'IS NUMERIC' clause? / What do you understand by the 'IS NUMERIC' clause in COBOL?

In the COBOL programming language, the 'IS NUMERIC' clause is used to check if an item is numeric or not. It returns the value as TRUE if the checked item contains only numbers (0 to 9). The item can be positive or negative.


10) What are level 66 and level 88 in the COBOL programming language?

In the COBOL programming language, level 66 is used in RENAMES clause, and level 88 is used for condition names.


11) What is a scope terminator in COBOL?

In COBOL, the scope terminator is used to mark the end of a verb. For example, IF and END-IF.


12) What is the difference between SEARCH and SEARCH ALL in COBOL?

In COBOL, the SEARCH command is used for serial search while the SEARCH ALL command is used for binary search where the table or array must be sorted using ASCENDING or DESCENDING key.


13) What is the difference between NEXT SENTENCE and CONTINUE?

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


14) What are the different modes of file opening in COBOL?

There are four modes of opening a file in COBOL. These are:

  • Input
  • Output
  • Input-Output
  • Extend

15) What is the maximum size of a numeric field that can be defined in COBOL?

The maximum size of a numeric field that can be defined in COBOL is PIC 9(18).


16) What is the difference between Static Linking and Dynamic Linking in COBOL?

In Static linking, the subroutine links into the calling program. On the other hand, in the dynamic linking, the key program and subroutine will remain separate modules. Static linking and dynamic linking can be achieved by link edit options- DYNAM or NODYNAM.


17) What are the main characteristics of the COBOL programming language as a business language?

COBOL is a programming language and a business-oriented application. It has many characteristics that can help businesses to manage and update data. As a business language, COBOL can handle large data volumes. It facilitates programmers to compile, execute and bring COBOL on many machines together. It can also be used for debugging and testing tools if it is required a debugging solution. Different versions of COBOL can enhance its features many times.


18) What is the use of EVALUATE statement in COBOL?

In COBOL, the EVALUATE statement is just like a case statement. It can also be used like a Nested IF. The main difference between an EVALUATE statement, and a case is that 'break' is not used in Evaluate statement, and the control comes out of the EVALUATE once a match is found.


19) What guidelines should we follow while writing a structured COBOL-based program?

While writing a structured COBOL based program, we must follow a certain format that allows the proper implementation of the code. For example, while constructing a case, we can use EQUIVALENT statements each time. While nesting, we should use scope terminators, and when we want the program to do something, we should try and use IN-LINE PERFORM statements. We can also use TEST BEFORE and TEST AFTER statements while coding for do-while loop statements.


20) What is the difference between PERFORM ... WITH TEST AFTER and PERFORM ... WITH TEST BEFORE?

PERFORM … WITH TEST BEFORE: If TEST BEFORE is specified, the condition is tested at the beginning of each repeated execution of the specified PERFORM range.

PERFORM … WITH TEST AFTER: 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.


21) What is the use of REPLACING option of a copy statement in COBOL?

In the COBOL programming language, the REPLACING option allows for the same copy to use many times if required. It changes the replace value in the same code.

Syntax:


22) What is the use of scope terminator in COBOL programming language?

In the COBOL programming language, the scope terminator is used to mark the end of a verb.

Example: IF and END-IF.


23) Why can we not define an Occurs clause at 01 levels?

We cannot define an Occurs clause at 01 levels because 01 is record level. We repeat the fields within a record, but not the record itself. So, we cannot use the Occurs clause at the 01 levels.


24) What is the role of the ON SIZE ERROR option in trapping error? / What kinds of errors are caught by the ON SIZE ERROR option?

The ON SIZE ERROR option is used to trap the following types of errors:

  • Fixed point overflow.
  • Number zero raised to power zero.
  • Division by zero
  • Number zero raised to negative power number.
  • A negative number raised to the power of a fraction

25) What is the difference between the structured COBOL program and the Object-Oriented COBOL Program?

Structured programming is the logical way of writing a program where functions are divided into modules and operated logically. COBOL is a structured and very user-friendly programming language. It is one of the oldest programming languages. The functionalities it provides for big administrative systems cannot be easily replaced. That's why it is alive and used nowadays also although it was invented a long ago.

Object-oriented COBOL programming is a natural way of programming in which objects are identified, and then functions and procedures are written around that Object. Object-oriented programs are run on a programming paradigm that relies on the concept of classes and objects. Here we write the methods and functions around the Object that is identified.


26) Which mode is used to open a file for writing?

To write into a file, we have to open either OUTPUT or EXTEND mode.


27) What should be the sorting order for SEARCH ALL?

The sorting order for SEARCH ALL can be either ASCENDING or DESCENDING. By default, it is ascending. If you want the search to be done on an array sorted in descending order, then you should give DESCENDING KEY clause while defining the array. It means you must load the table in the specified order.


28) What is the difference between Call By Content and Call By Reference in COBOL?

In Call By Content, the passed parameters are protected from modification by the called program. On the other hand, in Call By Reference, the called program can modify the parameters.


29) What do you understand by INPUT PROCEDURE and OUTPUT PROCEDURE in COBOL?

In INPUT PROCEDURE, the input file is opened, records are read and edited and then are released to the sorting operation. In the end, the file will be closed.

In the OUTPUT PROCEDURE, the output file is opened, the sorted record is returned to the Output record, and the record will be written. In the end, the file will be closed.


30) What is the difference between Call By Content and Call By Reference in COBOL?

In Call By Content, the passed parameters are protected from modification by the called program. On the other hand, in Call By Reference, the called program can modify the parameters.


31) What is the use of LINKAGE SECTION in COBOL programming?

In COBOL programming, the linkage section is used to pass data from one program to the other or pass data from a procedure to a program. It is part of a program that maps data items in the calling program's working storage.


32) What are the different access modes of the START statement?

There are two access modes in the START statement: SEQUENTIAL and DYNAMIC.


33) 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

34) Which program divisions are mandatory for a COBOL program?

Two program divisions, named identification division and Program ID, are mandatory for a COBOL program.


35) What are the different divisions in the COBOL programming language?

There are four major divisions in the COBOL programming language:

  • Identification Division: The Identification division starts the COBOL program and is a mandatory section in every COBOL program. The compiler and programmer use this division to identify the program. We must have to define the PROGRAM-ID (a keyword) immediately after the Identification division.
  • Environment Division: In the Environment division, we can define the input and output files of the program. This division is optional and mainly used to describe the system's environment in which the program will run.
  • Data Division: The data division contains information about the variables and data items used in the program. It also defines the variable names, their lengths, decimal locations, and the information about the storage formats.
  • Procedure Division: The procedure division is the most important section of the COBOL program. It is like the main() function of C/C++ program. From this division, the program starts the execution. The procedure division is the logical section of the program. Here all the business logic is written. Like the C/C++ main() function, all COBOL programs must have a procedure division. We can use the user-defined names and paragraphs in the procedure division. It is mandatory to specify at least one statement in this division as it cannot be left empty.

36) What is the difference between GOBACK, STOP RUN and EXIT PROGRAM in COBOL programming?

Following is the list of key differences between GOBACK, STOP RUN, and EXIT PROGRAM in COBOL:

  • GOBACK: This is used to return the control to the calling program.
  • STOP RUN: This is used to stop the present work unit and return the control to OS.
  • EXIT PROGRAM: This is used to leave a program that another program has called.

37) What is the difference between comp and comp-3 in COBOL?

In COBOL, comp is used to indicate binary usage. On the other hand, comp-3 is used to indicate a packed decimal.


38) What do you understand by DELIMITED BY SPACE and DELIMITED BY SIZE? What are their usages?

DELIMITED BY SPACE and DELIMITED BY SIZE is used along with the STRING for controlling the information if it is replicated.

  • DELIMITED BY SIZE: In DELIMITED BY SIZE, the total size of information would be considered the delimiter.
  • DELIMITED BY SPACE: In DELIMITED BY SPACE, the space would be considered as the delimiter.

39) What do you understand by Redefines clause?

The Redefines clause allows the same storage allocation to be referenced by different data names.


40) To conduct REWRITE, why is it mandatory that the file needs to be opened?

To conduct REWRITE, we must open the record and read it from the file. So, the file must be opened in I-O mode if you want to conduct a REWRITE function.


41) What do you understand by an IN-LINE PERFORM?

An IN-LINE PERFORM is a statement that allows the routine to be nested within the perform statement itself instead of a separate paragraph.

It uses two statements, PERFORM and END-PERFORM, to block the COBOL statements between them. IN-LINE PERFORM works as long as there are no internal GO TOs, not even to an exit.


42) What is the main purpose of using Pointer in the string?

A Pointer is used to specify the leftmost position within the receiving field where the first transferred character will be stored.


43) What is the difference between Global and External Variables?

The main difference between Global and External Variables is that the Global variables are accessible only to the batch program. On the other hand, External variables can be referenced from any batch program residing in the same system library.


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

Difference between a binary search and a sequential search

Binary SearchSequential Search
In Binary search, the table element key values are arranged in ascending or descending order. The table is 'halved' in this search technique to search for equal to, greater than or less than conditions until it finds the element.In the case of Sequential search, the table is searched from top to bottom. In this search technique, the elements are not required to be in a specific sequence.
For more tables, the binary search is the best and much faster.Sequential search works well with lesser tables.
For Binary search, SEARCH ALL is used.For sequential search, SEARCH is used.

45) What do you understand by Pic 9v99? What does it indicate?

Pic 9v99 is used to specify a three-position Numeric field. It contains an implied or assumed decimal point after the first position. Here, v means an implied or assumed decimal point.


46) What is the difference between PIC 9.99 and PIC9v99?

PIC 9.99 is a four-position field that contains a decimal point. On the other hand, the PIC 9v99 is three-position numeric field which have an implied or assumed decimal point.


47) What are the various rules used to perform a SEARCH?

We can apply a SEARCH to a table if it satisfies the following conditions:

  • If it has OCCURS clause
  • If it is INDEXED BY phrase
  • Search Index must have some initial value
  • Set the index value to 1

48) Which function is used to get the current date from the system with century?

To get the current date from the system with century, we can use the intrinsic function called FUNCTION CURRENT-DATE.


49) What are SSRANGE and NOSSRANGE in COBOL programming language?

In the COBOL programming language, SSRANGE and NOSSRANGE are options for a compiler to find the subscript out of range. NOSSRANGE is the default option where there will not be any run-time error if the Index or subscript went out of a range.


50) What are the various sections of data division?

There are a total of six sections in Data Division. Following is the list of them:

  • File Section
  • Working Storage Section
  • Local Storage Section
  • Screen Section
  • Report Section
  • Linkage Section

51) What is the difference between a Call and a Link in the COBOL programming language?

A Call is an actual COBOL command used to initiate an external program and returns in the COBOL programming language. On the other hand, a Link is the same as Call, but the only difference is that it does not belong to a COBOL verb.


52) What is the difference between comp and comp-3 usage?

Comp is used for binary usage, while comp-3 is used to specify packed decimal.


53) In which condition we can perform the SORT operation? What are the different rules of SORT operation?

We can perform the SORT operation in the following conditions:

  • When Input and Output files must remain closed.
  • When Input and Output files have FD entries.
  • When Working file must have a select clause.
  • When Work file should have a short description in File Section.

54) Is it possible to search a table with or without an Index?

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