COBOL Interview Questions and Answers
Ques 6. How do you handle errors in COBOL programs?
Errors in COBOL programs are often handled using the ON EXCEPTION clause or the use of condition names. This allows for the graceful handling of errors.
Example:
READ FILE-1 INTO WS-RECORD ON EXCEPTION
DISPLAY 'Error reading file'
END-READ.
Ques 7. Explain the difference between CALL and PERFORM in COBOL.
CALL is used to transfer control to another program or a specific paragraph within the same program. PERFORM is used for looping and invoking paragraphs or sections.
Ques 8. What is the purpose of the FILE SECTION in COBOL?
The FILE SECTION in COBOL is used to describe the structure and attributes of files used by the program. It includes the FD (File Description) entries.
Ques 9. How is indexing done in COBOL?
Indexing in COBOL is typically done using INDEXED BY clause. It associates an index name with a data item, allowing for efficient access to table elements.
Example:
01 EMPLOYEE-TABLE OCCURS 10 TIMES INDEXED BY EMPLOYEE-INDEX.
...
Ques 10. What is the purpose of the REDEFINES clause?
The REDEFINES clause in COBOL is used to share storage between two or more data items. It allows multiple data descriptions for the same physical storage.
Example:
01 EMPLOYEE-NAME PIC X(20).
01 EMPLOYEE-NAME-REDEFINED REDEFINES EMPLOYEE-NAME PIC 9(9).
Most helpful rated by users:
- What is COBOL?
- Explain the Division structure in COBOL.
- What is the purpose of the LEVEL number in COBOL?