Cobol Interview Questions and Answers
by Bhavya Sri, on Mar 29, 2018 10:57:12 AM
Q1. What is COBOL?
Q2. Which division and paragraphs 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?
Q8. What is difference between COBOL and VS COBOL II?
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?
Q12. How do you submit JCL via a COBOL program?
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?
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.
Q15. What is the difference between performing a SECTION and a PARAGRAPH?
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.