Iteanz Interview Questions | Latest Technologies Interview Questions

Cobol Interview Questions and Answers

Written by Rupa.R | Sep 10, 2022 9:07:34 AM
 
1. What is COBOL?

COBOL is abbreviated as Common Business Oriented Language and it is one of the oldest programming languages. It primarily used for business, finance and administrative systems for companies.

2. Which division and paragraphs are mandatory for a COBOL program?
 
  Identification division and Program ID are mandatory for a COBOL program.

3. How do you specify and use a cursor in a COBOL program?

Use DECLARE CURSOR statement either in working storage or in procedure division ( before open cursor), to specify the SELECT statement. Then use OPEN, FETCH rows in a loop and finally CLOSE.

4. What is a synonym?

A synonym is an unqualified alternative name for a table or view.

5. What is a foreign key?

A foreign key is the key defined in one table to reference the primary key of a reference table. This foreign key must have the same structure as the reference table’s primary key.

6. What is referential integrity?

Referential integrity is the automatic enforcement of referential constrains that exist between a reference table and a referencing table. When referential integrity is enforced, the value of a foreign key exists as a primary key value in the reference table. In other words, when referential integrity is enforced, all of the foreign key values in, for example, the “department code” column in an “employee” table exist as primary key values in a “department” talbe.

7. How do you define a table/array in COBOL?

ARRAYS. 05 ARRAY1 PIC X(9) OCCURS 10 TIMES. 05 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX.

8. What is difference between COBOL and VS COBOL II?

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.

9. How do you differentiate between COBOL and COBOL-II?

1. MVSXA and MVSESA support the compiler and the object programs it produces can be run in either 24- or 31-bit addressing mode.

2. VMXA and VMESA support the compiler and the object programs it produces can be run in either24- or 31-bit addressing mode.

3. VSEESA supports the compiler and the object programs it produces can be run under VSEESA.

The following features are available with VS COBOL II

 10. What is a correlation name?

A correlation name is a special type of column designator that connects specific columns in the various levels of a multilevel SQL query.

11. How to execute a set of JCL statements from a COBOL program?

Using EXEC CICS SPOOL WRITE (var-name) END-EXEC command. Var-name is a COBOL host structure containing JCL statements.
 
12. How do you submit JCL via a COBOL program?
 
Use a file //dd1 DD sysout=(*, intrdr)write your JCL to this file. Pl some on try this out.
 
13. What is the difference between Structured COBOL Programming and Object Oriented COBOL programming?

 Structured programming is logical way of programming where the functionalities are divided into modules and helps write the code logically.
Object Oriented Cobol language is a Natural way of programming in which you identify the objects, and then write functions and procedures around that object.

 
14. What are declaratives and what are their uses in cobol?
 
The declarative are used to provide special sections that are executed in case of exceptional condition occurrences. The declarative must be grouped and coded at the start of division of procedure. Also the entire procedure must be split into sections. A group of declarative always begin with DECLARATIVES and end by END DECLARATIVES in area A.
There are three types of declaratives used in COBOL.
  • Exception: They are used for errors that occur in a file handling procedure.
  • Debugging: As their name suggests, used for debugging lines with “D” code in w-s section.
  • Label: they are used to indicate a beginning.
15. What is the difference between performing a SECTION and a PARAGRAPH?
 
SECTION will have all the paragraphs that are part of the section, to be performed.
PARAGRAPH will have only that paragraph to be performed.

16. What happens when you say OPEN CURSOR?

If there is an ORDER BY clause, rows are fetched, sorted and made available for the FETCH statement. Other wise simply the cursor is placed on the first row.

17. What is the difference between SEARCH and SEARCH ALL? What is more efficient?

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.

18. What guidelines should be followed to write a structured COBOL prgm?

 1) Use ‘evaluate’ stmt for constructing cases.

2) Use scope terminators for nesting.

3) Use in line performs stmt for writing ‘do ‘constructions.

4) Use test before and test after in the perform stmt for writing do-while constructions.

19. What is the difference between a binary search and a sequential search? What are the pertinent COBOL commands?

  • In a binary search the table element key values must be in ascending or descending sequence.
  • The table is ‘halved’ to search for equal to, greater than or less than conditions until the element is found.
  • In a sequential search the table is searched from top to bottom, so (ironically) the elements do not have to be in a specific sequence.
  • The binary search is much faster for larger tables, while sequential works well with smaller ones.
  • SEARCH ALL is used for binary searches; SEARCH for sequential.

20. What is LENGTH in COBOL II?

LENGTH acts like a special register to tell the length of a group or elementary item.