FAQs(1 to 15)

1) Name the divisions in a COBOL program ?.


2) What are the different data types available in COBOL?

A) Alpha-numeric (X), alphabetic (A) and numeric (9).

3) What does the INITIALIZE verb do? 

A) Alphabetic, Alphanumeric fields & alphanumeric edited items are set to SPACES. Numeric, Numeric edited items set to ZERO. FILLER , OCCURS DEPENDING ON items left untouched.

4) What is 77 level used for ?

A) Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themselves.

5) What is 88 level used for ?

A) For condition names.

6) What is level 66 used for ?

A) For RENAMES clause.

7) What does the IS NUMERIC clause establish ?

A) IS NUMERIC can be used on alphanumeric items, signed numeric & packed decimal items and unsigned numeric & packed decimal items. IS NUMERIC returns TRUE if the item only consists of 0-9. However, if the item being tested is a signed item, then it may contain 0-9, + and - .

8) How do you define a table/array in COBOL?




9) Can the OCCURS clause be at the 01 level?

A) No.

10) What is the difference between index and subscript? 

A) Subscript refers to the array occurrence while index is the displacement (in no of bytes) from the beginning of the array.

An index can only be modified using PERFORM, SEARCH & SET. Need to have index for a table in order to use SEARCH, SEARCH ALL.

11) What is the difference between SEARCH and SEARCH ALL? 

A) SEARCH - is a serial search.

SEARCH ALL - is a binary search & the table must be sorted ( ASCENDING/DESCENDING KEY clause to be used & data loaded in this order) before using SEARCH ALL.

12) What should be the sorting order for SEARCH ALL? 

A) It can be either ASCENDING or DESCENDING. ASCENDING is default. If you want the search to be done on an array sorted in descending order, then while defining the array, you should give DESCENDING KEY clause. (You must load the table in the specified order).

13) What is binary search?

A) Search on a sorted array. Compare the item to be searched with the item at the center. If it matches, fine else repeat the process with the left half or the right half depending on where the item lies.

14) My program has an array defined to have 10 items. Due to a bug, I find that even if the program access the

11th item in this array, the program does not abend. What is wrong with it?

A) Must use compiler option SSRANGE if you want array bounds checking. Default is NOSSRANGE.

15) How do you sort in a COBOL program? Give sort file definition, sort statement syntax and meaning.

A) Syntax: SORT file-1 ON ASCENDING/DESCENDING KEY key.... USING file-2 GIVING file-3.

USING can be substituted by INPUT PROCEDURE IS para-1 THRU para-2

GIVING can be substituted by OUTPUT PROCEDURE IS para-1 THRU para-2.

file-1 is the sort (work) file and must be described using SD entry in FILE SECTION.

file-2 is the input file for the SORT and must be described using an FD entry in FILE SECTION and SELECT

clause in FILE CONTROL.

file-3 is the out file from the SORT and must be described using an FD entry in FILE SECTION and SELECT

clause in FILE CONTROL.

file-1, file-2 & file-3 should not be opened explicitly.

INPUT PROCEDURE is executed before the sort and records must be RELEASEd to the sort work file from the input procedure.

OUTPUT PROCEDURE is executed after all records have been sorted. Records from the sort work file must be RETURNed one at a time to the output procedure.