COBOL Interview Questions and Answers
Ques 46. What is the purpose of the REJECT statement in COBOL?
The REJECT statement in COBOL is used to return a record to an input file after it has been read. It is often used in conjunction with the REWRITE statement.
Example:
READ INPUT-FILE INTO DATA-RECORD.
IF CONDITION
REJECT DATA-RECORD.
END-IF.
Ques 47. Explain the concept of the COMPUTATIONAL-3 clause.
The COMPUTATIONAL-3 (COMP-3) clause in COBOL is used to define packed-decimal data items. It represents decimal numbers in a packed format for efficient storage.
Example:
01 AMOUNT PIC 9(5) COMP-3.
Ques 48. What is the purpose of the ALTER statement in COBOL?
The ALTER statement in COBOL is used to modify the properties of data items at runtime. It allows dynamic changes to the length, picture, or usage of data items.
Example:
ALTER ITEM-DESCR TO PIC X(30).
Ques 49. Explain the concept of the EXIT SECTION statement.
The EXIT SECTION statement in COBOL is used to terminate the current section prematurely. It allows the program to skip the remaining code within a particular section.
Example:
PERFORM PROCESS-DATA SECTION.
IF ERROR-FLAG = 'Y' THEN
EXIT SECTION.
END-IF.
Ques 50. What is the purpose of the GENERATE statement in COBOL?
The GENERATE statement in COBOL is used to dynamically create new paragraphs or sections during program execution. It enhances the flexibility and adaptability of the program.
Example:
GENERATE 'NEW-PARAGRAPH'.
Most helpful rated by users: