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.

What is FD and SD in COBOL?

FD is used to specify the file description entry for logical-file-name. SD is used to specify the sort file description entry for logical-file-name.

Where to define the file structure in COBOL program?

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

How do you declare and use a data structure in COBOL, and what is its purpose?

Logical file structure definition has the definition of the file logical structure that is needed to process the data in the program. The logical structure is the copybook layout used to map the file record.

What is the fixed length record in COBOL program?

Fixed length record specifies the file record length has a single value. For example - Declaration for the fixed-length record of length 80.

RECORD CONTAINS 80 CHARACTERS

What is the variable length in COBOL program?

Variable length record specifies the file record length has in between a range of values. For example - Declaration for the variable-length record of length 80 to 100.

RECORD CONTAINS 80 TO 100 CHARACTERS

How do you know the length of the record you are processing?

RECORD CONTAINS clause provides the length of the record.

How to identify a file is fixed (F) blocking file?

Fixed means that one physical block on disk is one logical record and all the blocks and records are the same size. For example - Declaration for the fixed blocking file.

ORGANIZATION IS SEQUENTIAL
RECORDING MODE IS F
BLOCK CONTAINS 0

How to identify a file is fixed block (FB) file?

This format designation means that several logical records are combined into one physical block. For example - Declaration for the fixed-block file.

ORGANIZATION IS SEQUENTIAL
RECORDING MODE IS FB
BLOCK CONTAINS 0

How will you define a Variable block file in COBOL?

This format places several variable-length logical records in one physical block. For example - Declaration for the variable-block file.

RECORDING MODE IS VB

How can you identify if the file is a variable block file?

RECORDING MODE clause defines the file as variable blocked file.

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?