COBOL Interview Questions and Answers : Part 1

10/01/2009 No Comment

Latest COBOL Interview Questions and Answers collected from job interviews.

What is a re-entrant program? How will you make a program Reentrant?
Answer : A re-entrant program, while being executed resides in the common virtual area so that one copy of it may be shared among all callers. Use RENT compiler option.

What is the difference between a 01 level and 77 level?
Answer : 01 level can have sublevels from 02 to 49. 77 cannot have sublevel.

What are the few advantages of VS COBOL II over OS/VS COBOL?
Answer : The working storage and linkage section limit has been increased. They are 128 megabytes as supposed to 1 megabytes in OS/VS COBOL. Introduction of ADDRESS special register.
31-bit addressing. In using COBOL on PC we have only flat files and the programs can access only limited storage, whereas in VS COBOL II on M/F the programs can access up to 16MB or 2GB depending on the addressing and can use VSAM files to make I/O operations faster.

What are the steps you go through while creating a COBOL program executable?

Answer : DB2 pre-compiler (if embedded SQL is used), CICS translator (if CICS program), Cobol compiler, Link editor. If DB2 program, create plan by binding the DBRMs.

What are the minimum requirements to compile a program without errors?

Answer : Identification Division. Program-ID. Program-name.
A) Is compute w=u a valid statement?
Yes, it is. It is equivalent to move u to w.
B) In the above example, when will you prefer compute statement over the move statement?
When significant left-order digits would be lost in execution, the COMPUTE statement can detect the condition and allow you to handle it. The MOVE statement carries out the assignment with destructive truncation. Therefore, if the size error is needs to be detected, COMPUTE will be preferred over MOVE. The ON SIZE ERROR phrase of COMPUTE statement, compiler generates code to detect size-overflow.

What happens when the ON SIZE ERROR phrase is specified on a COMPUTE statement?

Answer : If the condition occurs, the code in the ON SIZE ERROR phrase is performed, and the content of the destination field remains unchanged. If the ON SIZE ERROR phrase is not specified, the assignment is carried out with truncation. There is no ON SIZE ERROR support for the MOVE statement.

How will you associate your files with external data sets where they physically reside?

Answer : Using SELECT clause, the files can be associated with external data sets. The SELECT clause is defined in the FILE-CONTROL paragraph of Input-Output Section that is coded Environment Division. The File structure is defined by FD entry under File-Section of Data Division for the OS.

How will you define your file to the operating system?

Answer : Associate the file with the external data set using SELECT clause of INPUT-OUTPUT SECTION. INPUT-OUTPUT SECTION appears inside the ENVIRONMENT DIVISION.
Define your file structure in the FILE SECTION of DATA DIVISION.

Explain the use of Declaratives in COBOL?

Answer : Declaratives provide special section that are executed when an exceptional condition occurs. They must be grouped together and coded at the beginning of procedure division and the entire procedure division must be divided into sections. The Declaratives start with a USE statement. The entire group of declaratives is preceded by DECLARIVES and followed by END DECLARITIVES in area A. The three types of declaratives are Exception (when error occurs during file handling), Debugging (to debug lines with 'D' coded in w-s section) and Label (for EOF or beginning...) declaratives.

A statically bound subprogram is called twice. What happens to working-storage variables?

Answer : The working-storage section is allocated at the start of the run-unit and any data items with VALUE clauses are initialized to the appropriate value at the time. When the subprogram is called the second time, a working-storage items persist in their last used state. However, if the program is specified with INITIAL on the PROGRAM-ID, working-storage section is reinitialized each time the program is entered.

When is COMMON attribute used?

Answer : COMMON attribute is used with nested COBOL programs. If it is not specified, other nested programs will not be able to access the program. PROGRAM-ID. Pgmname is COMMON PROGRAM.

In which division and section, the Special-names paragraph appears?

Answer : Environment division and Configuration Section.
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