COBOL Interview Questions and Answers
Ques 26. What is the purpose of the COPY statement in COBOL?
The COPY statement in COBOL is used for including copybooks in the source code. It allows the reuse of common code and improves maintainability.
Example:
COPY 'COMMON-FILE'.
Ques 27. Explain the concept of the ACCEPT statement.
The ACCEPT statement in COBOL is used for interactive input. It allows the program to receive data directly from the user during runtime.
Example:
ACCEPT EMPLOYEE-NAME.
Ques 28. How does COBOL support data validation?
COBOL supports data validation through the use of conditions, the IF statement, and the EVALUATE statement. These constructs help ensure data integrity.
Example:
IF AMOUNT < 0
DISPLAY 'Invalid amount'
END-IF.
Ques 29. Explain the purpose of the EXIT statement.
The EXIT statement in COBOL is used to terminate a loop prematurely. It allows the program to exit a PERFORM loop or a Section before reaching the normal end.
Example:
PERFORM UNTIL EOF-FLAG = 'Y'
...
IF SOME-CONDITION
EXIT.
END-IF.
END-PERFORM.
Ques 30. What is the role of the WORKING-STORAGE section in COBOL?
The WORKING-STORAGE section in COBOL is used to declare variables that retain their values throughout the execution of the program. It provides working storage for temporary data.
Example:
WORKING-STORAGE SECTION.
01 COUNTER PIC 9(3) VALUE 0.
Most helpful rated by users: