File Declaration Interview Questions


How to declare the files in COBOL?

A file should be declared with all its characteristics for processing in the application program. If it is not declared, the program is unaware of the file. Programs use these things to define the file's characteristics, such as the file type, length, recording mode, etc., and start processing the file.

In which COBOL section do you assign your file?

SELECT clause is used to map the logical-file-name with the physical file external to the program.

Where to define the file structure in COBOL program?

The logical file structure definition should be in the FILE SECTION of DATA DIVISION.

How can we reference or make COBOL program realise that about the following file formats?

  1. Fixed Block File - Declaration of fixed block file is -
    ORGANIZATION IS SEQUENTIAL
    RECORDING MODE IS F
    BLOCK CONTAINS 0
  2. Fixed Unblock File - Declaration of fixed unblock file is -
    ORGANIZATION IS SEQUENTIAL
    RECORDING MODE IS F
  3. Variable Block File - Declaration of variable block file is -
    ORGANIZATION IS SEQUENTIAL
    RECORDING MODE IS V
    BLOCK CONTAINS 0
  4. Variable Unblock File - Declaration of fixed unblock file is -
    ORGANIZATION IS SEQUENTIAL
    RECORDING MODE IS V
  5. Printer File - Declaration of printer file is -
    ORGANIZATION IS SEQUENTIAL
    RECORDING MODE IS F
    BLOCK CONTAINS 0

Frequently Asked Questions -

Where to define file in COBOL?

Which COBOL section do you define your file structure?