Top Interview Questions & Answers | Learn Now

Cobol Interview Questions and Answers | Basic and Advanced Levels

Written by Bhavya Sri | Mar 29, 2018 5:27:12 AM

Q1. What is COBOL?

 
Ans: 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.
 

Q2. Which division and paragraphs are mandatory for a COBOL program?

 
Ans: Identification division and Program ID are mandatory for a COBOL program.
 

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

Ans: 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.

Q4. What is a synonym?

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

Q5. What is a foreign key?

Ans: 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.

Q6. What is referential integrity?

Ans: 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.

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

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

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

Ans: 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.
 

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

Ans:

  • MVSXA and MVSESA support the compiler and the object programs it produces can be run in either 24- or 31-bit addressing mode.
  • VMXA and VMESA support the compiler and the object programs it produces can be run in either24- or 31-bit addressing mode.
  • VSEESA supports the compiler and the object programs it produces can be run under VSEESA.

The following features are available with VS COBOL II.

Q10. What is a correlation name?

 

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

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

Ans: Using EXEC CICS SPOOL WRITE (var-name) END-EXEC command. Var-name is a COBOL host structure containing JCL statements.
 

Q12. How do you submit JCL via a COBOL program?

 
Ans: Use a file //dd1 DD sysout=(*, intrdr)write your JCL to this file. Pl some on try this out.
 

Q13. What is the difference between Structured COBOL Programming and Object Oriented COBOL programming?

 

Ans: 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.

Q14. What are declaratives and what are their uses in cobol?

 
Ans: 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:

  1. Exception: They are used for errors that occur in a file handling procedure.
  2. Debugging: As their name suggests, used for debugging lines with “D” code in w-s section.
  3. Label: they are used to indicate a beginning.

Q15. What is the difference between performing a SECTION and a PARAGRAPH?

 
Ans: SECTION will have all the paragraphs that are part of the section, to be performed.
PARAGRAPH will have only that paragraph to be performed.
 

Q16. What happens when you say OPEN CURSOR?

Ans: 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.

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

Ans: 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.

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

Ans:

  • Use ‘evaluate’ stmt for constructing cases.
  • Use scope terminators for nesting.
  • Use in line performs stmt for writing ‘do ‘constructions.
  • Use test before and test after in the perform stmt for writing do-while constructions.

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

Ans:

  • 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.

Q20. What is LENGTH in COBOL II?

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