Top 50+ Interview Questions


1. What is COBOL, and what does it stand for?

COBOL is an acronym for COmmon Business-Oriented Language, primarily developed for business, finance, and administrative system needs.

2. Describe the history and evolution of COBOL?

COBOL is a high-level programming language initially developed by the CODASYL Committee in the early 1960s.

  • First COBOL Compiler - CODASYL developed in the early 1960s and assigned to the ANSI for improvements. The addressing mode feature of AMODE 16 (16-bit).
  • ANSI COBOL 1968 - ANSI developed a standard form of the language in 1968 to overcome incompatibility between different versions and called it as ANS COBOL.
  • COBOL 1974 (OS/VS COBOL) - ANSI published a revised version of (ANS) COBOL, which contains an additional set of features. The addressing mode feature of AMODE 24 (24-bit).
  • VS COBOL II (1988) - ANSI published another revised version with new features like scope terminators, including END-IF, END-PERFORM, END-READ, etc. The new feature of AMODE 31 (31-bit).
  • Enterprise COBOL 2002 and object-oriented COBOL - IBM, Fujitsu, and Micro Focus were involved in developing object-oriented syntax and introduced object-orientation features. It was approved by the ISO and published in late 2002.
  • Enterprise COBOL v4.1 (2007) - COBOL 2002 suffered from poor support, and no compilers completely supported the object-oriented standard. So the most popular revised version was developed and released with the standard compiler's support in 2007.
  • Enterprise COBOL v6.3 (2019) - It is developed with AMODE (64-bit), UTF-8, intoduces some new compiler options.
  • Enterprise COBOL v6.4 (2022) - Enterprise COBOL 6.4 is the current version and developed with COBOL/Java interoperability, interoperability between AMODE 31 (31-bit) and AMODE 64 (64-bit)

3. What are the primary features of COBOL?

The main features of the COBOL language are -

  • COBOL is simple
  • Standard Language
  • COBOL is stable
  • Business Oriented
  • Structured
  • Robust
  • Easy to read
  • Easy to Learn
  • Self-documenting

4. Describe the basic structure of a COBOL program?

COBOL program structure is a top-to-bottom hierarchical design, consisting of Divisions, Sections, Paragraphs, Sentences, Statements, and Character strings.

  • A COBOL statement is a combination of COBOL keywords and operands.
  • A sentence is a sequence of two or more statements ended by a period (.).
  • A paragraph is a block of code consisting of one or more sentences or statements.
  • A section is a collection of one or more related paragraphs within the PROCEDURE DIVISION.
  • A division is a collection of one or more sections and paragraphs.

5. Explain the concept of a paragraph and a section?

A paragraph is a block of code consisting of one or more sentences or statements. It represents a logical code unit and can be called or performed by other parts of the program.

6. What are the different divisions in a COBOL program, and what do they contain?

COBOL has 4 system-defined divisions. They are -

  • IDENTIFICATION DIVISION
  • ENVIRONMENT DIVISION
  • DATA DIVISION
  • PROCEDURE DIVISION

7. What is a level number in COBOL, and why is it important? Describe the significance of the level number in COBOL data definitions?

Level numbers play the most important role in declaring the variables in the application programs. They specify the hierarchy or level of data items or variables.

8. Explain the concept of hierarchical level numbering?

The hierarchical level numbering is used to specify the level of the variable declaration.

9. What are the different levels of data hierarchy?

The level number hierarchy starts from 01 through 49.
The hierarchy of level numbers should be in ascending order. i.e., 01 is the highest level number, and 49 is the lowest level number.

10. How do you declare variables?

For Example - Declaring a variable of numeric type to store a value 123.

 01 WS-NUMERIC-VAR      PIC 9(03) VALUE 123.
  • level-number - Refers the level number. From the example, it is 01.
  • variable-name - Refers the name of the variable. From the example, it is WS-NUMERIC-VAR.
  • data-type-character - Refers the type of the variable. From the example, it is numeric(9).
  • variable-length - Refers the variable length. From the example, it is 03.
  • literal-value - Refers the initial value assigned to the variable. From the example, it is 123.

11. What are the different data types supported by COBOL?

There are five data types in COBOL, and those are -

  • Alphabetic
  • Alpha-numeric
  • Numeric
  • Sign
  • Decimal Point

12. Describe the different types of condition names?

Condition name has the advantage of being used in three different formats, which are very useful in validating the data. Those are -

  • Condition names with Single Value
  • Condition names with Multiple values
  • Condition names with Range of values

13. Explain the concept of a picture clause?

PICTURE clause specifies the characteristics of the variable while declaring it, e.g., variable type, length, etc.

14. What is the purpose of the REDEFINES clause?

REDEFINES defines a new variable for the existing variable, which means two variables share the same memory area.
It is a way to declare multiple variables for a single memory area in different ways based on the requirement.

15. How do you perform arithmetic operations?

COBOL has dedicated statements to perform Arithmetic operations instead of using inline operators like other programming languages. These statements allow developers to perform addition, subtraction, multiplication, division, and more complex computations.

16. How do you handle decimal arithmetic?

We can use assumed or real decimal point data type to declare or store the decimal point values. These variables can directly use in arithmetic operations.

17. How do you handle the USING and GIVING clauses?

USING clause is used to send the data from main program or receive the data in sub program.
GIVING phrase specifies the output variables are used to store the result of arithmetic operators and are not part of the inputs.

18. Explain the concept of data manipulation?

Data manipulation is the process of organizing or rearranging data in order to make it easier to process.

19. What are the different types of statements available in the PROCEDURE DIVISION of a COBOL program?

PROCEDURE DIVISION statements are divided into three categories based on their actions, and they are -

  • Imperative Statements
  • Conditional Statements
  • Delimited scope statements

20. What is the significance of the WORKING-STORAGE SECTION?

It is used to declare all the variables and record structures required for processing data in the program.

21. What is the significance of the INITIALIZE statement?

INITIALIZE sets the variables with system-defined initial values based on their data types.

22. How do you handle input and output operations?

Input-output statements manage data transfer between the program's internal storage and external input or output devices. The input-output statements are –

  • ACCEPT Statement
  • DISPLAY Statement

23. What is the purpose of the ACCEPT and DISPLAY statements?

Input output statements

24. Explain the concept of a MOVE statement?

MOVE statement is used to transfer data from the source data item to the target data item. It ensures that the transferred data is appropriately formatted based on the data types and sizes of the source and destination fields.

25. How do you handle conditional statements?

A conditional statement derives a condition's truth value (TRUE or FALSE), and decides the further program execution flow. These statements allow decision-making in the program based on the evaluation of conditions. The conditional statements are -

  • IF Statement
  • EVALUATE Statement
  • Statements with conditional phrases

26. Explain the difference between the EVALUATE and IF statements?

IFEVALUATE
It validates a single condition at a time It validates the multiple conditions at a time
It has the forms - Simple IF, IF..ELSE, nested IF..ELSE It is a shorter form for the nested IF...ELSE

27. Describe the different types of loops available?

Iterative programming involves making a set of statements run in a repetitive, iterative, or looping manner. In iterative programming, the statements execute repeatedly until the coded condition is true. The PERFORM statement is part of iterative programming in COBOL and is also called a looping statement.

28. What is the significance of the PERFORM statement?

PERFORM statement executes the statement block repeatedly. The repetitive execution can be conditional or unconditional. If any condition is coded with it, the statements block gets executed until the coded condition is true.

29. How do you handle the SET and PERFORM VARYING statements?

SET statement is used to perform the below operations - initializing, increasing or decreasing table indexes and setting the condition name to true or false.
PERFORM...VARYING executes a specific paragraph or section repetitively while varying the values of the variables until the condition is satisfied.

30. How do you perform table handling?

COBOL arrays are also known as tables. Array is a collection of individual data items of same type and length. It is a linear data structure that uses to store the identical data repeated multiple times. For example - student marks for all subjects.

Table data can be accessed by using subscript or index.
Index is always declared with table and initialized, increment or decrement by SET statement.
It is automatically created with the OCCURS clause. But, it needs a separate WORKING-STORAGE variable that should delcare as S9(04) COMP.

31. How do you perform table searching?

Table searching can be done in two ways -

  • Search
  • Search All

32. What is a subscript in COBOL, and how is it used?

Table data can be accessed by using subscript. Subscript represents the number of table occurrences. It is automatically created with the OCCURS clause. But, it needs a separate WORKING-STORAGE variable that should delcare as S9(04) COMP.

33. How do you perform string manipulation?

String handling statements are used to handle and manipulate strings. These statements are essential for processing textual data, allowing for modifications, evaluations, and extractions of character data within a COBOL program. They are -

  • STRING
  • UNSTRING
  • INSPECT

34. How do you handle file processing?

COBOL file processing refers to the operations carried out on data files, like reading, writing, updating, and deleting records. When writing a COBOL program, it's important to choose the appropriate file processing method based on the nature of the data and the operations that will be performed on it.

34. Explain the concept of file handling modes?

The file access modes specify how data is read from or written to files. COBOL supports three access modes -

  • Sequential access mode
  • Random access mode
  • Dynamic access mode

36. What are the different file organizations supported by COBOL?

File organization is the method used to store and arrange data records within a file. COBOL primarily supports three types of file organizations -

  • Sequential File Organization
  • Indexed File Organization
  • Relative File Organization

37. What is the significance of the FILE-CONTROL paragraph?

FILE-CONTROL paragraph contains complete information about the files used in the program. It maps the logical file defined in the program to the corresponding physical file in the JCL by using DDname or DSName in CICS.

38. What is the significance of the SELECT and ASSIGN clauses?

SELECT clause is used to assign the logical-file-name (8 character) with the physical file external to the program.

39. Describe the purpose of the FD and SD entries?

FD specifies the file description entry for the physical file.
SD specifies the sort description entry for work files.

40. How do you perform record-level processing?

Record-level processing allows COBOL programs to manipulate individual records within files, enabling tasks such as data retrieval, modification, and deletion. Here are the statements used for record-level processing in COBOL -

  • READ
  • WRITE
  • REWRITE
  • DELETE
  • START & READ NEXT

41. How do you handle sequential and random-access files?

Records are accessed one after another in the order they appear in the file. Sequential access mode applicable to -

  • Sequential files
  • Indexed files
  • Relative files

Records are accessed based on a specific key value, allowing for the direct retrieval of any record without knowing its position or reading the preceding ones. Random access mode applicable to -

  • Indexed files
  • Relative files

42. Explain the difference between the OPEN and CLOSE statements?

OPEN statement establishes a connection between the logical file and its associated physical file. It opens the file for subsequent processing (e.g., reading, writing, updating).
CLOSE statement is used to terminate the file processing and release the resources of the file.

43. What is the difference between the READ and WRITE statements?

READ statement is used to retrieve a record from the file. At a time, only one record is retrieved from the file.
WRITE statement is used to add a record to the file. At a time, only one record is written to the file.

44. How do you handle COBOL file status codes?

COBOL file status codes provide information about the result of each file operation executed. For example - Declaring a file status variable and using to handle the errors.

      ...
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           ... 
           FILE STATUS  IS WS-FS1.

       DATA DIVISION.
       ...
       WORKING-STORAGE SECTION.
       01 WS-FS1        PIC X(02) VALUE ZERO.

       PROCEDURE DIVISION.
           OPEN INPUT EMPFILE. 
           PERFORM UNTIL WS-FS1 NOT = '00'
                READ EMPFILE 
                     NOT AT END DISPLAY EMPFILE-RECORD
                END-READ
           END-PERFORM.
           CLOSE EMPFILE. 
		   
           STOP RUN.
  • The file status (WS-FS1) is typically a two-character code.
  • The first character is the general code, and the second provides further detailed information.

45. Describe the significance of the LINKAGE SECTION?

LINKAGE SECTION is used for - passing data between programs and receiving data from run JCL.

46. How do you pass parameters between programs?

Parameters can be passed between programs using the CALL and USING statements. The CALL statement is used to invoke a subprogram (called program) from another program (calling program), and the USING clause is used to pass parameters between them.

47. Explain the concept of CALL statements?

A CALL statement statement is used to transfer the control from one program to another to complete a task.

48. What is the purpose of the GOBACK statement?

GOBACK defines the logical end of a program and gives the control back from where it was received. It can code in both the main program and subprogram.

49. What is the purpose of the CANCEL statement?

CANCEL is used to release the resources associated with a previously called subprogram. If the subprogram is no longer needed, it is used to free up the resources used by the subprogram.

50. What is the difference between static and dynamic calls?

Static callsDynamic calls
STATIC CALL attaches the SUBPROG load module to the MAINPROG load module to increase processing speed DYNAMIC CALL removes the compilation dependency of MAINPROG when the SUBPROG is modified
Load modules of MAINPROG and SUBPROG are stored togetherLoad modules of MAINPROG and SUBPROG are separately stored
Compiler option should be NODYNAMCompiler option should be DYNAM
Its execution is fasterIts execution is a little slower when compared with STATIC CALL
Can be used on request basis nowadaysIt is the most used one nowadays

51. How do you handle subroutine calls?

Subroutine calls are handled using the PERFORM or CALL statements. PERFORM statement is used to execute a sequence of statements within the same program, while the CALL statement is used to invoke another program or subroutine.

52. What are the different types of SORT operations available?

Below statements are used in internal sort process -

  • SORT Statement
  • MERGE Statement

53. Describe the purpose of the SORT statement?

SORT statement is a powerful statement used for sorting files internally within the program. It's mainly useful in batch processing, where large amounts of data need to be sorted before further processing.

54. What is the purpose of the USAGE clause?

USAGE clause explains how data is stored in memory and how the calculations are performed on that data. Different USAGE modes, such as BINARY, PACKED-DECIMAL, and DISPLAY, specify the internal representation of the data.

55. What is the role of the RETURN statement?

RETURN statement transfers records from the final phase of a sorting or merging operation to an OUTPUT PROCEDURE. It is used only within the OUTPUT PROCEDURE associated with a SORT or MERGE statement.

56. How do you handle error handling and exception handling?

Error handling is a mechanism used to handle the possible runtime errors by notifying the user with a message or routing the program flow to skip the program abend.

57. How do you handle date and time manipulation?

ACCEPT statement used to receive the system-related information during the program execution. The system-related information is DATE, DATE YYYYMMDD, DAY, DAY YYYYDDD, DAY-OF-WEEK, or TIME.

58. Explain the concept of nested programs?

Nested programs in COBOL refer to the practice of including one program within another program. This allows for modular programming where smaller, reusable programs (called subprograms) are encapsulated within larger programs (called main programs).

59. Describe the concept of COPY and REPLACE statements?

COPY statement includes predefined copybooks (usually file record structures) from the library that is outside of the program.
COPY...REPLACING replaces the source-string with the target string.