File Processing Interview Questions


What is file processing?

COBOL file processing refers to the operations carried out on data files, like reading, writing, updating, and deleting records.

What are the file processing statement?

Below are the file processing statements -

  • OPEN File
  • READ
  • WRITE
  • REWRITE
  • DELETE
  • START & READ NEXT
  • CLOSE File

File OPEN -

Why file OPEN is required?

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).

What are the file opening modes in COBOL?

The list of file opening modes are -

  • INPUT
  • OUTPUT
  • I-O
  • EXTEND

File READ -

How do you read data from a file in COBOL?

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

File WRITE -

How do you write data to a file in COBOL?

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

File REWRITE -

Which COBOL verb do you use for updating a file?

REWRITE

Why rewrite statements used in programming?

REWRITE statement is used to replace the content of a previously read record with new data. At a time, only one record is replaced in the file.

File DELETE -

What is the mode used to delete the record in the file?

I-O

What is the delete statement does?

DELETE statement removes a record from an indexed or relative file.

File START -

Which command is used to place the cursor on a specific record?

START

What is the use of START statement?

START is used to set the file pointer to read the record.

File READ NEXT -

What is the use of READ NEXT statement in COBOL?

READ NEXT statement is used to read the next record from the current reading position of the file.

What are the prerequisites before using READ NEXT?

START statement should be executed before READ NEXT.

File CLOSE -

Is it always mandatory to close the file?

No. All opened files will be automatically closed when the program execution completed.

Frequently Asked Questions -

What is the use of file OPEN statement?

What are the allowed opening modes for sequential files in COBOL?
What are the allowed opening modes for indexed and relative files in COBOL?

How do you update a file in COBOL?

Why should the file be opened in I-O mode when it is being used for REWRITE purposes?

To conduct REWRITE, why is it mandatory that the file needs to be opened?

What are the access modes of START statement?

What statement should issue before READ NEXT?