4.Which mode of opening is required when REWRITE is used?
-
UPDATE
-
OPEN
-
I-O
-
INPUT
I-O (Input-Output) mode is required when using REWRITE in COBOL file operations. REWRITE modifies an existing record in a file, which requires the file to be opened in I-O mode to allow both reading and writing. UPDATE is not a valid file open mode in COBOL, OPEN is a verb not a mode, and INPUT mode only allows reading.
COBOL's REWRITE statement updates an existing record in a file that has already been read, and this requires the file to be opened in I-O mode (Input-Output) so both reading and rewriting are permitted on the same open. OPEN and INPUT modes don't allow rewriting records, and UPDATE isn't a valid COBOL open mode keyword (the valid modes are INPUT, OUTPUT, I-O, and EXTEND). Hence I-O is the only correct choice.