Friends as you know COBOL (Common Business-Oriented Language) is one of the oldest programming languages, but it is still used in many banks, government offices, and big companies. If you are preparing for a Cobol Interview Questions 2025, it’s important to understand the basic concepts, common questions, and how to answer them.
In this article, we will cover important COBOL interview questions in a simple way. Whether you are a beginner or have some experience, this guide will help you feel more confident. Let’s get started!
Contents
- 1 Cobol Interview Questions 2025
- 1.1 1. What is COBOL, and why is it still used today?
- 1.2 2. What are the four divisions of a COBOL program?
- 1.3 3. What is the difference between COMP and COMP-3 in COBOL?
- 1.4 4. How do you declare a variable in COBOL?
- 1.5 5. What is the difference between SEARCH and SEARCH ALL in COBOL?
- 1.6 6. What is the purpose of the OCCURS clause in COBOL?
- 1.7 7. What is a Subscript and an Index in COBOL?
- 1.8 8. How do you handle errors in COBOL?
- 1.9 9. What is the difference between PERFORM and CALL in COBOL?
- 1.10 10. What is the difference between STATIC and DYNAMIC CALL in COBOL?
- 1.11 11. What is the difference between CONTINUE and NEXT SENTENCE in COBOL?
- 1.12 12. What is the difference between STOP RUN and EXIT PROGRAM in COBOL?
- 1.13 13. What is the difference between WORKING-STORAGE and LINKAGE SECTION?
- 1.14 14. How do you define a file in COBOL?
- 1.15 15. What are the different types of COBOL files?
- 1.16 16. How do you perform a SORT operation in COBOL?
- 1.17 17. What is REDEFINES in COBOL?
- 1.18 18. What is the use of INITIALIZE in COBOL?
- 1.19 19. What is the purpose of INSPECT in COBOL?
- 1.20 20. What are the different types of PERFORM statements in COBOL?
- 1.21 21. What is the difference between COMP-1 and COMP-2 in COBOL?
- 1.22 22. What is the significance of COPY and INCLUDE statements in COBOL?
- 1.23 23. How do you handle table overflow in COBOL?
- 1.24 24. What is an EVALUATE statement in COBOL?
- 1.25 25. What is the purpose of STRING and UNSTRING in COBOL?
- 1.26 26. What is the use of SET in COBOL?
- 1.27 27. What is the difference between GLOBAL and EXTERNAL in COBOL?
- 1.28 28. What are the different types of report writing statements in COBOL?
- 1.29 29. How does COBOL handle dates?
- 1.30 30. What is the purpose of USING in a CALL statement?
Cobol Interview Questions 2025
1. What is COBOL, and why is it still used today?
Answer: COBOL (Common Business-Oriented Language) is a high-level programming language mainly used in business, finance, and administrative systems. It is still used today because many banks, insurance companies, and government systems rely on old COBOL programs that are stable and secure.
Explanation: COBOL is considered outdated by some, but businesses continue to use it because rewriting these systems in modern languages would be costly and time-consuming.
2. What are the four divisions of a COBOL program?
Answer: The four divisions of a COBOL program are:
- Identification Division – Provides program details like name and author.
- Environment Division – Specifies hardware and file setup.
- Data Division – Defines variables and data structures.
- Procedure Division – Contains the main logic and instructions.
Explanation: Every COBOL program is structured with these divisions to keep the code organized and easy to understand.
3. What is the difference between COMP and COMP-3 in COBOL?
Answer:
- COMP (Computational) stores numbers in binary format, making it faster for calculations.
- COMP-3 (Packed Decimal) stores numbers in a compressed decimal format, saving space.
Explanation: COMP is best for high-speed calculations, while COMP-3 is used for financial data where precision is important.
4. How do you declare a variable in COBOL?
Answer:
Variables are declared in the Data Division under the Working-Storage Section like this:
01 EMPLOYEE-NAME PIC X(30).
01 EMPLOYEE-SALARY PIC 9(7)V99.
Explanation:
PIC X(30)
defines a text variable with 30 characters.PIC 9(7)V99
defines a numeric variable with 7 digits before the decimal and 2 after (V
represents the decimal point).
5. What is the difference between SEARCH and SEARCH ALL in COBOL?
Answer:
- SEARCH is used for a sequential search in an indexed table.
- SEARCH ALL is used for a binary search, which is faster but requires the table to be sorted first.
Explanation: If the data is sorted, SEARCH ALL is preferred because it finds results faster using binary search.
6. What is the purpose of the OCCURS clause in COBOL?
Answer: The OCCURS clause defines arrays (tables) in COBOL. Example:
01 EMPLOYEE-NAMES.
05 NAME OCCURS 10 TIMES PIC X(20).
Explanation: This creates an array that can store 10 names, each up to 20 characters long, reducing code repetition.
7. What is a Subscript and an Index in COBOL?
Answer:
- Subscript is a number that represents the position in an array (e.g.,
NAME(3)
). - Index is a special pointer used in indexed tables, making access faster.
Explanation: Indexing is more efficient than subscripts when working with large tables because it avoids repeated calculations.
8. How do you handle errors in COBOL?
Answer: COBOL provides FILE STATUS codes and EXCEPTION handling using ON SIZE ERROR
. Example:
IF TOTAL-SALARY > 9999999
DISPLAY "Salary Limit Exceeded"
ON SIZE ERROR
DISPLAY "Calculation Error".
Explanation: This helps in catching errors like numeric overflow and taking proper action.
9. What is the difference between PERFORM and CALL in COBOL?
Answer:
- PERFORM is used to execute a section or paragraph within the same program.
- CALL is used to call an external COBOL program.
Explanation: Use PERFORM for repeating code within the same program, and CALL when you need to use another COBOL program’s functionality.
10. What is the difference between STATIC and DYNAMIC CALL in COBOL?
Answer:
- STATIC CALL: The called program is linked at compile time, making execution faster but increasing program size.
- DYNAMIC CALL: The called program is loaded at runtime, making it more flexible but slightly slower.
Explanation: Static calls are used when the subprogram is fixed, while dynamic calls are used when different subprograms might be needed at runtime.
11. What is the difference between CONTINUE and NEXT SENTENCE in COBOL?
Answer:
- CONTINUE acts as a placeholder and does nothing—it just moves to the next statement.
- NEXT SENTENCE moves control to the next period (
.
) and executes the following statement.
Explanation: NEXT SENTENCE can accidentally skip code if used incorrectly, so CONTINUE is safer in structured programs.
12. What is the difference between STOP RUN and EXIT PROGRAM in COBOL?
Answer:
- STOP RUN terminates the entire program, including subprograms.
- EXIT PROGRAM ends only the called subprogram and returns control to the calling program.
Explanation: Use STOP RUN in main programs and EXIT PROGRAM in subprograms to avoid unintended program termination.
13. What is the difference between WORKING-STORAGE and LINKAGE SECTION?
Answer:
- WORKING-STORAGE SECTION stores variables that belong to the current program.
- LINKAGE SECTION defines variables that are passed from another program.
Explanation: The LINKAGE SECTION is used in subprograms to access data sent by the main program.
14. How do you define a file in COBOL?
Answer:
Files are defined in the File Section of the Data Division. Example:
FD EMPLOYEE-FILE.
01 EMPLOYEE-RECORD.
05 EMP-ID PIC 9(5).
05 EMP-NAME PIC X(30).
05 EMP-SALARY PIC 9(7)V99.
Explanation:
FD
(File Description) defines the file.01 EMPLOYEE-RECORD
defines the record structure for reading/writing.
15. What are the different types of COBOL files?
Answer:
- Sequential Files – Read and written in order.
- Indexed Files – Use a key to access records directly.
- Relative Files – Access records using relative positions.
Explanation: Indexed and relative files allow faster data access than sequential files, which require reading from the beginning.
16. How do you perform a SORT operation in COBOL?
Answer:
COBOL provides the SORT statement:
SORT SORT-FILE ON ASCENDING KEY EMP-ID
USING INPUT-FILE
GIVING OUTPUT-FILE.
Explanation:
- SORT-FILE is a temporary file used for sorting.
- USING specifies the input file.
- GIVING sends sorted records to the output file.
17. What is REDEFINES in COBOL?
Answer:
The REDEFINES clause allows one variable to use the same memory space as another. Example:
01 EMP-DATA.
05 EMP-ID PIC 9(5).
05 EMP-NAME PIC X(30).
05 EMP-SALARY PIC 9(7)V99.
05 EMP-DETAILS REDEFINES EMP-NAME PIC X(40).
Explanation: This helps in memory optimization, allowing different data interpretations without extra space.
18. What is the use of INITIALIZE in COBOL?
Answer:
The INITIALIZE statement resets variables based on their type:
INITIALIZE EMPLOYEE-RECORD.
Explanation:
- Alphanumeric fields (
PIC X
) are set to spaces. - Numeric fields (
PIC 9
) are set to zeros.
19. What is the purpose of INSPECT in COBOL?
Answer:
The INSPECT statement is used for string operations like counting or replacing characters. Example:
INSPECT CUSTOMER-NAME TALLYING COUNT-OF-A FOR ALL 'A'.
Explanation: This counts the number of ‘A’ characters in CUSTOMER-NAME and stores the result in COUNT-OF-A.
20. What are the different types of PERFORM statements in COBOL?
Answer:
- PERFORM THRU – Executes a range of paragraphs.
- PERFORM UNTIL – Repeats a block until a condition is met.
- PERFORM VARYING – Loops with a counter.
- PERFORM TIMES – Runs a block a fixed number of times.
Example of PERFORM UNTIL:
PERFORM DISPLAY-NAMES UNTIL EMP-ID = 99999.
Explanation: This keeps executing DISPLAY-NAMES until EMP-ID = 99999
.
21. What is the difference between COMP-1 and COMP-2 in COBOL?
Answer:
- COMP-1 (Single-precision floating point) stores approximate decimal values using 4 bytes.
- COMP-2 (Double-precision floating point) stores more precise decimal values using 8 bytes.
Explanation: COMP-2 is used for high-precision calculations, while COMP-1 is used when precision is not critical.
22. What is the significance of COPY and INCLUDE statements in COBOL?
Answer:
- COPY is used to include reusable code from an external file at compile time.
- INCLUDE (used in DB2-COBOL) includes SQL statements dynamically during pre-compilation.
Example of COPY:
COPY EMPLOYEE-RECORD.
Explanation: COPY reduces redundancy and maintains common code easily.
23. How do you handle table overflow in COBOL?
Answer:
By checking the subscript or index before accessing the table:
IF SUB > 100
DISPLAY "Table Overflow".
Explanation: Prevents reading/writing beyond the allocated table size, avoiding runtime errors.
24. What is an EVALUATE statement in COBOL?
Answer:
EVALUATE works like a CASE or SWITCH statement in other languages:
EVALUATE EMP-RANK
WHEN "Manager" DISPLAY "Senior Level"
WHEN "Executive" DISPLAY "Mid Level"
WHEN OTHER DISPLAY "Junior Level"
END-EVALUATE.
Explanation: This makes decision-making simpler than using multiple IF statements.
25. What is the purpose of STRING and UNSTRING in COBOL?
Answer:
- STRING joins multiple strings into one.
- UNSTRING splits a string into parts.
Example of STRING:
STRING "Mr. " FIRST-NAME SPACE LAST-NAME INTO FULL-NAME.
Example of UNSTRING:
UNSTRING ADDRESS DELIMITED BY "," INTO CITY STATE ZIP.
Explanation: These commands help in handling text processing efficiently.
26. What is the use of SET in COBOL?
Answer:
SET assigns values to indexes or pointers:
SET INDEX-NAME TO 1.
Explanation: Used in indexed tables and pointers to improve efficiency.
27. What is the difference between GLOBAL and EXTERNAL in COBOL?
Answer:
- GLOBAL: A variable declared in a program can be used in its subprograms.
- EXTERNAL: A variable is shared across different programs.
Explanation: GLOBAL is limited to one program and its subprograms, while EXTERNAL allows sharing between completely separate programs.
28. What are the different types of report writing statements in COBOL?
Answer:
COBOL provides REPORT WRITER statements like:
- RD (Report Description) – Defines the report structure.
- FD (File Description) – Defines report files.
- GENERATE – Produces a report line.
Explanation: The REPORT WRITER feature is useful for automatic report formatting but is rarely used in modern COBOL programs.
29. How does COBOL handle dates?
Answer:
COBOL provides Intrinsic Functions for date manipulation:
COMPUTE AGE = FUNCTION INTEGER-OF-DATE(TODAY) - FUNCTION INTEGER-OF-DATE(BIRTH-DATE).
Explanation: This calculates the age by converting dates into integer format for easy subtraction.
30. What is the purpose of USING in a CALL statement?
Answer:
The USING clause is used to pass parameters between programs:
CALL 'SUBPROGRAM' USING EMP-ID EMP-NAME.
Explanation: It allows data sharing between main and subprograms, making the program modular.
Also Read-