COBOL Interview Questions Answers 4

11/02/2009 No Comment

COBOL Interview Questions Answers for professionals. 

Please use the comment section to provide more relevant answers.

What are the access mode requirements of START statement?
Answer : Access mode must be SEQUENTIAL or DYNAMIC

What are the opening mode requirements of START statement?
Answer : Files must be opened in the INPUT or I-O mode.

What are the different rules of SORT that needs to be considered? 

Answer : The input and output files must remain closed because SORT opens them and closes during the operation, The work file must have a SELECT clause. The work file must have sort description SD entry in the FILE SECTION. Input and Output files must have FD entries

How will you position an indexed file at a specific point so that the subsequent sequential operations on the file can start from this point?
Answer : Use START
START filename KEY IS EQ/GT/LT.. dataname
INVALID KEY ...

What is an in line PERFORM? When would you use it? 

Answer : The PERFORM and END-PERFORM statements bracket all COBOL II statements between them. The COBOL equivalent is to PERFORM or PERFORM THRU a paragraph. In line PERFORMs work as long as there are no internal GO TOs, not even to an exit. The in line PERFORM for readability should not exceed a page length - often it will reference other PERFORM paragraphs. When the body of the Perform will not be used in other paragraphs. If the body of the Perform is a generic type of code (used from various other places in the program), it would be better to put the code in a separate para and use PERFORM paraname rather than in-line perform.

What is the use of EVALUATE statement? How do you come out of an 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, There is no need of any extra code. EVALUATE can be used in place of the nested IF THEN ELSE statements.

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 increment or decrements it 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. 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 COBOL statements.

What are INPUT PROCEDURE and OUTPUT PROCEDURE? 

Answer : Sometimes, it is necessary that the records must be edited before or after the sorting. In such cases,SORT workfile ASC/DESC KEY key1, ...
INPUT PROCEDURE IS ipproc
OUTPUT PROCEDURE is outproc


Is used. In the INPUT PROCEDURE the input file is opened, records are read and edited and then are released to the sorting operation. Finally the file is closed. RELEASE sortrecname FROM inp-rec.
In the OUTPUT PROCEDURE, output file is opened, the sorted record is returned to the Output record area and then the record is written. Finally the file is closed. RETURN workfile RECORD into out-rec.

What is the LINKAGE SECTION used for? 

Answer : The linkage section is used to pass data from one program to another program or to pass data from a PROC to a program. It is part of a called program that 'links' or maps to data items in the calling program's working storage. It is the part of the called program where these share items are defined.

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. Indexing uses binary displacement. Subscripts use the value of the occurrence.
Related Posts


No comments :

 

Aired | The content is copyrighted and may not be reproduced on other websites. | Copyright © 2009-2016 | All Rights Reserved 2016

Contact Us | About Us | Privacy Policy and Disclaimer