Cobol interview questions

Question 1: What is binary search?
Answer : 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.

Question 2: My program has an array defined to have 10 items. Due to a bug, 1 find that even if the program access the 11th item in this array, the program does not abend. What is wrong with it?
Answer : Must use compiler option SSRANGE if you want array bounds checking. Default is NOSSRANGE.

Question 3: How do you define a sort file in JCL that runs the COBOL program?
Answer : Use the SORTWKOl, SORTWK02, dd names in the step. Number of sort datasets depends on the volume of data being sorted, but a minimum of 3 is required.

Question 3a:) What is the difference between performing a SECTION and a PARAGRAPH?
Performing a SECTION will cause all the paragraphs that are part of the section, to be performed. Performing a PARAGRAPH will cause only that paragraph to be performed.

Question 4: What is the use of EVALUATE statement?
Answer : Evaluate is like a case statement and can be used to replace nested Ifs. The difference between EVALUATE and case is that no ’break’ is required for EVALUATE i.e. control comes out of the EVALUATE as soon as one match is made.

Question 5 : Can you call an OS VS COBOL pgm from a VS COBOL II pgm ?
Answer : In non-CICS environment, it is possible. In CICS, this is not possible.

Question 6 : What are the differences between COBOL and COBOL II?
Answer : There are at least five differences:
COBOL II supports structured programming by using in line Performs and explicit scope terminators. It introduces new features (EVALUATE, SET. TO TRUE, CALL. BY CONTEXT, etc) It permits programs to be loaded and addressed above the 16-megabyte line It does not support many old features (READY TRACE, REPORT-WRITER, ISAM, Etc.), and It offers enhanced CICS support.

Question 7 : What is an explicit scope terminator?
Answer : A scope terminator brackets its preceding verb, e.g. IF .. END-IF, so that all statements between the verb and its scope terminator are grouped together. Other common COBOL II verbs are READ, PERFORM, EVALUATE, SEARCH and STRING.

Question 8: What is the difference between a subscript and an index in a table definition?
Answer : A subscript is a working storage data definition item, typically a PIC (999) where a value must be moved to the subscript and then incremented or decrements by ADD TO and SUBTRACT FROM statements. An index is a register item that exists outside the program’s working storage. You SET an index to a value and SET it UP BY value and DOWN BY value.

Question 9 : If you were passing a table via linkage, which Is preferable – a subscript or an index?
Answer : Wake up – you haven’t been paying attention! It’s not possible to pass an index via linkage. The index is not part of the calling programs working storage. Those of us who’ve made this mistake, appreciate the lesson more than others.

Question 10: Explain the difference between an internal and an external sort, the pros and cons, internal sort syntax etc.
Answer : An external sort is not COBOL; it is performed through JCL and PGM=SORT. It is understandable without any code reference. An internal sort can use two different syntax’s: 1.) USING, GIVING sorts are comparable to external sorts with no extra file processing; 2) INPUT PROCEDURE, OUTPUT PROCEDURE sons allow for data manipulation before and/or after the son.

Author: user

Leave a Reply