Level Numbers Interview Questions


What is a level number in COBOL?

Level numbers play the most important role in declaring the variables in the application programs. They specify the hierarchy or level of data items or variables.

How many types of level numbers based on its usage?

Level numbers are of two types based on their usage purpose -

  • General purpose level numbers (01 to 49)
  • Special purpose level numbers (66, 77 and 88)

What is the general-purpose level numbers?

General purpose level numbers declare regular variables that simply process the data. The level number hierarchy starts from 01 to 49.

What is highest level number in the hierarchy?

01

What is the least level number in hierarchy?

49

What is the maximum size of a 01 level item in COBOL II?

In COBOL II, the maximum size of a 01 level item is 16777215 bytes.

Elementary items cannot be divided further. Level number, Data name, Picture clause and Value clause (optional) are used to describe an elementary item. State whether True or False?

False

66 Level Number -

What is level 66 used for?

Level number 66 is used to create another logical group by regrouping the elementary variables of a group. RENAMES keyword is used along with the 66-level number to rename the group.

Explain some rules for 66 level numbers?

  • Renaming elementary variables should be in sequential order.
  • 66 level number shouldn't have a PIC or PICTURE clause.
  • The RENAMES clause should follow the target variable in the declaration.
  • Level-01, level-77, level-88, or other level-66 entries can't be renamed.
  • Elementary variables that are declared with the OCCURS clause should not be renamed.

Can I rename an X(100) group field with a field of X(200)?

No. Not possible.

Can I rename an X(200) group field with a field of X(100)?

Yes

77 Level Number -

What is 77 level used for?

Variables have no immediate relationship to any other variables. Those variables are called Individual variables. Special purpose level number 77 is to declare individual variables.

Explain some rules for 77 level number?

  • Individual variables declaration should begin in Area A.
  • These variables should not be coded under any group.
  • These variables can’t be divided into elementary variables.
  • These variables should not be coded in the FILE SECTION.
  • Independent variable names should be unique in the program.

88 Level Number -

What is 88 level used for?

88-level number provides a descriptive name for a condition. The name associated with 88 level numbers is called as Condition Name, and the variable with 88 level numbers attached to it is called as Conditional Variable.

How the condition names is declared in COBOL program?

For example -

 01 WS-GENDER       PIC X(01) VALUE 'M'.
   88 MALE         VALUE 'M'.
   88 FEMALE       VALUE 'F'.

The declaration below initializes the WS-GENDER with 'M', which sets the MALE condition name to true.

What is the different formats in defining condition names?

Condition name has the advantage of being used in three different formats, which are very useful in validating the data. Those are -

  • Condition names with Single Value
  • Condition names with Multiple values
  • Condition names with Range of values

Explain some rules for 88 level number?

  • No PICTURE clause is associated with 88-level numbers.
  • 88 level number is always associated with level number 01-49.
  • The VALUE clause is mandatory for the condition name.
  • The keywords THROUGH and THRU are equivalent.
  • Condition names can be coded both at the group and elementary levels.

Common Questions -

Difference the between level numbers 01 and 77?

  • The variables declared with 01-level numbers have an extra byte allocated because there is a chance that the variable can be grouped in the future and can use the extra byte as a pointer to the elementary items.
  • However, the variables declared with 77 level numbers do not have any extra byte allocated as the declaration specifies that the variable is individual. So, Level 77 reduces memory usage during runtime, with no extra byte being used.

Frequently Asked Questions -

What is the significance of level numbers in COBOL?

What is 01 to 49 level number in COBOL?

What are 66 and 88 level used for?
When do you use 66 and 88 levels in COBOL?
What are level 66 and level 88 in the COBOL programming language?

What are levels 66, 77 and 88 used for?
What are the uses of 66, 77 and 88 levels?

Define the function of using the special level number 88 in programming?
What is the major role of using the special variable number 88 in COBOL?