Cobol interview questions

Question 21: How do you set a return code to the JCL from a COBOL program?
Answer : Move a value to RETURN-CODE register. RETURN-CODE should not be declared in your program.

Question 22: How can you submit a job from COBOL programs?
Answer : Write JCL cards to a dataset with //xxxxxxx SYSOUT= (AJNTRDR) where ’A’ is output class, and dataset should be opened for output in the program. Define a 80 byte record layout for the file.

Question 23 : In a COBOL II PERFORM statement, when is the conditional tested, before or after the perform execution?
Answer : In COBOL II the optional clause WITH TEST BEFORE or WITH TEST AFTER can be added to all perform statements. By default the test is performed before the perform.

Question 24 : In an EVALUTE statement is the order of the WHEN clauses significant?
Answer : Absolutely. Evaluation of the WHEN clauses proceeds from top to bottom and their sequence can determine results.

Question 25 : What is the default value(s) for an INITIALIZE and what keyword allows for an override of the default.
Answer : INITIALIZE moves spaces to alphabetic fields and zeros to alphanumeric fields. The REPLACING option can be used to override these defaults.

Question 26: What is LENGTH in COBOL II?
Answer : LENGTH acts like a special register to tell the length of a group or elementary item.

Question 27: What is the difference between SEARCH and SEARCH ALL? What is more efficient?
Answer : SEARCH is a sequential search from the beginning of the table. SEARCH ALL is a binary search, continually dividing the table in two halves until a match is found. SEARCH ALL is more efficient for tables larger than 70 items.

Question 28 : What are some examples of command terminators?
Answer : END-IF, END-EV ALU ATE

Question 29 : What care has to be taken to force program to execute above 16 Meg line?
Answer : Make sure that link option is AMODE=31 and RMODE=ANY. Compile option should never have SIZE(MAX). BUFSIZE can be 2K, efficient enough.

Question 30: What are different file OPEN modes available in COBOL?
Answer : Open for INPUT, OUTPUT, I-O, EXTEND.

Author: user

Leave a Reply