File Accessing Modes Interview Questions
What are the accessing modes in COBOL?
The file access modes specify how data is read from or written to files.
What are the file access modes in COBOL?
COBOL supports three access modes -
- Sequential access mode
- Random access mode
- Dynamic access mode
What is sequential access mode?
Records are accessed one after another in the order they appear in the file.
What types of files allowed to open in sequential access mode?
Sequential access mode applicable to -
- Sequential files
- Indexed files
- Relative files
How to code the sequential access mode in COBOL?
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
...
ACCESS MODE IS SEQUENTIAL
What is random access mode?
Records are accessed based on a specific key value, allowing for the direct retrieval of any record without knowing its position or reading the preceding ones.
What types of files allowed to open in random access mode?
Random access mode applicable to -
- Indexed files
- Relative files
How to code the random access mode in COBOL?
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
...
ACCESS MODE IS RANDOM
What is dynamic access mode?
A combination of both SEQUENTIAL and RANDOM access modes. The type of access (sequential or random) can be chosen during runtime based on the operations we perform.
What types of files allowed to open in dynamic access mode?
Dynamic access mode applicable to -
- Indexed files
- Relative files
How to code the dynamic access mode in COBOL?
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
...
ACCESS MODE IS DYNAMIC