COBOL was created to accomplish two major objectives: one related to portability (the ability of programs to be run with minimum modification on computers from different manufacturers) and the other to readability (the ease with which a program can be read like ordinary English). This language was widely used in the 1990s.
Many people find it difficult to crack COBOL interviews. Many times candidates often fail at interviews because there are so many COBOL interview questions to be cracked. These questions are related to COBOL Programming Language, mainframe interview questions, and so on.
Usually, good interviewers do not plan to ask any particular question during the interview. Normally COBOL interview questions start with some basic concepts related to the subject. Here they test the candidate’s basic knowledge, and later they continue based on further discussion and what candidates answer in COBOL interview questions.
Here are some of the top 50 tricky mainframe COBOL interview questions:
1. What do you know about COBOL?
Commonly known as Common Business Oriented Language, COBOL is one of the oldest programming languages used mainly for various business verticals, including government functions, finance, and administrative systems. It focuses on solving complex business problems.
2. Is COBOL still used, or is it still worth learning?
Yes, COBOL is still worth learning, irrespective of the fact whether the user or programmer wants to maintain them or port them to any other programming languages. With COBOL, it could be done easily. The language is more than 60 years old, but recently, there has been a rise in demand for this due to the requirements of some government agencies. Recently programmers have been using COBOL in state government operations to handle unemployment benefits amid the pandemic.
3. What are the different data types of COBOL language?
There are three main data types in COBOL:
Numeric (X) – This is used to represent numeric values between 0-9 in COBOL programming
Alphabetic – This type of COBOL can hold any of the alphabetic variables ranging between A-Z
Alpha Numeric – This data type can hold both values together, be it alphabetic or numeric.
4. What is the difference between index and subscript?
Though Subscript is known as the occurrence of an array, an index refers to the displacement from the array’s beginning. One can only modify an index by using PERFORM, SEARCH & SET.
5. What is the difference between a section and a paragraph?
In a section, there will be all the paragraphs that are part of the section yet to be performed. While in the case of a paragraph, there will only be a paragraph to be performed.
6. What is the difference between NEXT SENTENCE & CONTINUE?
NEXT SENTENCE is used for transferring control to the next sentence. CONTINUE acts like a null statement, and it continues execution
7. What are the characteristics of COBOL as a business language?
COBOL is a business-oriented application. It has many characteristics that help businesses to manage and update data. Being a business language, COBOL can handle large data volumes. Programmers can compile, execute and bring together COBOL on many machines together. It can also be used for debugging and testing tools when somebody is looking for solutions. Different versions of COBOL enhance its features manifold.
Some of the features of COBOL language are:
8. What guidelines should one follow while writing a structured COBOL-based program?
When writing a structured COBOL program, one must follow a certain format that allows the proper implementation of the code. For instance, when constructing a case, one can use EQUIVALENT statements each time. When nesting, use scope terminators, and when you want the program to do something, try and use IN-LINE PERFORM statements. People also use TEST BEFORE and TEST AFTER statements while coding for do-while loop statements.
9. What are the divisions in a COBOL program?
There are around four divisions in a COBOL program. These are known as identification, environment, data and procedure. The identification is the most important division as it identifies the program. The environment division is divided into two sections, configuration and input-output. It defines the environment of the written program. The data division is used to identify data items, allocate memories, and define names within the program. It has a file, working storage and linkage section. The procedure division supports the logic behind the program. It must have at least one statement for using variables defined by the user.
10. What is the role played by the ACCEPT verb?
The ACCEPT verb is a basic statement used in COBOL for retrieving data like time, date and day from the user or program. In the educational data, ACCEPT verb and DISPLAY are used to receive information for a student record.
11. What are static and dynamic linking?
In static linking, subroutine links are called into the calling program. In dynamic linking, the subroutine & the main program can exist as separate modules. Dynamic and Static linking can be done by either choosing the DYNAM or NODYNAM link edit options.
12. What is the application of EVALUATE statement?
Evaluate is like a case statement. It can be used like Nested IFs. There is a difference between EVALUATE and case. In EVALUATE, ‘break’ is not used, and the control comes out of the EVALUATE once a match is found.
13. What is the significance of the REPLACING option of a copy statement?
The REPLACING option allows for the same copy to be used many times; it changes the replace value in the same code.
The coding used is COPY <Name> REPLACING BY
14. What is the role played by the ON SIZE ERROR option in trapping error?
ON SIZE ERROR option is used in the following cases:
Zero raised to the zero power
Division by 0
Zero raised to a negative number
A negative number raised to a fractional power
15. What are the differences between Structured COBOL Programming and Object-Oriented COBOL programming?
Structured programming can be defined as a logical way of programming. In this, the functionalities are divided into modules and help the programmer to write the code logically.
Object-Oriented COBOL is a natural way of programming. In this, programmers identify the objects and then write functions and procedures around that object.
16. How can you define LOCAL-STORAGE SECTION?
Each time the program is called, Local-Storage is allocated, and then it is deallocated when the program stops via an EXIT PROGRAM, GOBACK, or STOP RUN. It is defined in the DATA DIVISION after WORKING-STORAGE SECTION.
17. How can you define INPUT PROCEDURE and OUTPUT PROCEDURE?
During the INPUT PROCEDURE, the input file is opened, records are read and edited. These records are then released to the sorting operation. Finally, the file will be closed.
While in the OUTPUT PROCEDURE, the output file is opened, the sorted record is returned to the Output record, and then the record will finally be written. After this, the file will be closed.
18. What is the application of LINKAGE SECTION?
The linkage section is used to pass data from one program to the other or pass data from a procedure to a program. It is part of a program that maps data items in the calling program’s working storage.
19. Define access modes of START statement?
Access modes are defined as SEQUENTIAL or DYNAMIC for the start statement.
20. Define an in-line PERFORM?
Through an IN-LINE PERFORM statement, the routine is being performed to be nested within the perform statement instead of being a separate paragraph.
While the PERFORM and END-PERFORM statements are used to block the COBOL statements between them, in line PERFORM work as long as there are no internal GO TOs, not even to an exit.
21. Which program divisions are mandatory for a COBOL program?
Identification division and the Program ID.
22. What are the differences between Global and External Variables?
Global variables are available only to the batch program, while external variables can be accessed from any batch program in the same system library.
23. What is the meaning of Pic 9v99?
Pic 9v99 refers to a three-position numeric field with an implied or assumed decimal point after the first position.
Here, v stands for an implied decimal point.
24. What are the guidelines one must follow while writing a structured COBOL program?
One must follow certain guidelines while writing COBOL. They are mentioned below:
Using the ‘EVALUATE’ statement for constructing cases
Using scope terminators for nesting
Using in-line Perform statement for writing ‘do’ constructions
Using Test Before and Test After in the Perform statement while writing Do-While statements
25. How to find out the current date from a system with the century?
To find out the current date with the century, use an Intrinsic function called Function Current Date.
26. What are the various divisions of COBOL?
A COBOL program has 4 divisions:
27. What is the difference between SSRANGE and NOSSRANGE?
Both SSRANGE and NOSSRANGE are options for a compiler to find the out-of-range subscript. NOSSRANGE is the default option wherein there will not be any run-time error if the index or subscript went out of a range.
28. What is the difference between COMP-1? COMP-2?
COMP-1 is a single-precision floating-point and uses only 4-bytes. While COMP2 is the double-precision floating number and uses 8-bytes.
29. What is the use of the 77 level?
This is the Elementary level item. It cannot be put in subdivisions of other items (cannot be qualified), neither can they be subdivided themselves.
30. What is the use of 88 level?
It is used for condition names.
31. What is the use of level 66?
This level is used for RENAMES clause.
32. What is the use of the IS NUMERIC clause?
IS NUMERIC is used on alphanumeric items, signed numeric & packed decimal items. It is also used for unsigned numeric & packed decimal items. IS NUMERIC returns TRUE if the item only comprises of 0-9. However, if the item being tested is a signed item, then it may contain 0-9, + and -.
33. Can the OCCURS clause happen at the 01 level?
No. OCCURS clause cannot happen at the 01 level.
34. What do you understand by index and subscript?
Subscript means the array occurrence, while the index is the displacement (in bytes) from the start of the array. An index can only be modified using PERFORM, SEARCH & SET.
Programmers need to have an index for a table in order to use SEARCH, SEARCH ALL.
35. What is the sorting order for SEARCH ALL?
Searching orders for SEARCH ALL can be either ASCENDING or DESCENDING. ASCENDING is the default one. If you want the search to be done on an array sorted in descending order, then while defining the array, you should give DESCENDING KEY clause. (You must load the table in the specified order).
36. What is a binary search?
A binary search is a search done on a sorted array. One can compare the item to be searched with the item at the centre. If it matches with the item then it is fine, else, repeat the process with the left half or the right half, depending on where the item lies.
37. How is sorting done in a COBOL program?
Sorting is done in the following way:
SORT file-1 ON ASCENDING/DESCENDING KEY key…
USING can be substituted by INPUT PROCEDURE IS para-1 THRU para-2
GIVING can be substituted by OUTPUT PROCEDURE IS para-1 THRU para-2.
file-1 is the sort workfile and must be described using SD entry in FILE SECTION.
file-2 is the input file for the SORT and must be described using an FD entry in FILE SECTION and SELECT clause in FILE CONTROL.
file-3 is the outfile from the SORT and must be described using an FD entry in FILE SECTION and SELECT clause in FILE CONTROL.
file-1, file-2 & file-3 should not be opened explicitly.
INPUT PROCEDURE is executed before the sort, and records must be RELEASEd to the sort work file from the input procedure.
OUTPUT PROCEDURE is executed after all records have been sorted. Records from the sort work file must be RETURNed one at a time to the output procedure.
38. What are the different types of EVALUATE statements?
EVALUATE EVALUATE SQLCODE ALSO FILE-STATUS
WHEN A=B AND C=D WHEN 100 ALSO ’00’
imperative stmt imperative stmt
WHEN (D+X)/Y = 4 WHEN -305 ALSO ’32’
imperative stmt imperative stmt
WHEN OTHER WHEN OTHER
imperative stmt imperative stmt
EVALUATE SQLCODE ALSO A=B EVALUATE SQLCODE ALSO TRUE
WHEN 100 ALSO TRUE WHEN 100 ALSO A=B
imperative stmt imperative stmt
WHEN -305 ALSO FALSE WHEN -305 ALSO (A/C=4)
imperative stmt imperative stmt
39. What is a scope terminator? Explain by giving examples.
Scope terminator is used for marking the end of a verb. Examples are EVALUATE, END-EVALUATE, IF, END-IF.
40. What is the use of Pointer in the string?
The main purpose of Pointer is to specify the leftmost position within the receiving field where the first transferred character will be stored.
41. How can you differentiate between a binary search and a sequential search?
In the case of a binary search, the table element key values will be in ascending or descending order. The table is ‘halved’ to search for equal to, greater than or less than conditions until the element is found.
In case of a sequential search, the table is searched from top to bottom. For this, the elements do not have to be in a specific sequence.
The binary search is much faster for more tables, while sequential Search works very well with lesser tables. SEARCH ALL is used for binary search, while SEARCH is used for sequential search.
42. What are various rules to perform a SEARCH?
The SEARCH can be applied to a table with the following conditions:
Which has OCCURS clause
INDEXED BY phrase
Search Index must have some initial value
Set the index value to 1
43. In what case is a scope terminator mandatory?
Scope terminators are mandatory for in-line PERFORMS and EVALUATE statements. Make scope terminator explicit for good coding standards.
44. Why does the file always need to be opened in I-O mode for REWRITE purposes?
Even before the REWRITE is performed, the record must be opened and read from the file. For the same purpose, the file must be opened in I-O mode for REWRITE functionality.
45. Which of the Search verbs is equivalent to PERFORM…VARYING?
The serial SEARCH verb is equivalent to the Perform-Varying statement, and it is nothing but search without ALL.
46. What are various sections of data division?
There are a total of six sections in Data Division:
Working Storage Section
Local Storage Section
47. What is the difference between the usage of COMP and COMP-3?
COMP is used for the binary purpose, while COMP-3 indicates packed decimals.
48. What steps to follow to make a COBOL program suitable?
In order to make the COBOL program suitable, one must follow these steps:
· DB2 precompiler (if embedded SQL used)
· CICS translator (if CICS pgm)
· Cobol compiler
· Link editor
If DB2 program, create plan by binding the DBRMs
49. Highlight the difference between Call and a Link?
A call is an actual COBOL command, which initiates an external program and returns. While Link is the same as Call but the only difference is that it does not belong to a COBOL verb.
50. What mode is used for operating the sequential file and how can you define arrays in COBOL?
For operating a sequential file, an O-I mode (Output/Input mode) is used at the start and initiation of the processing files. Then Processing of files is determined by the successful execution of an OPEN statement.
In COBOL, arrays can be defined in the following way:
05 Array1 PIC X(9), which occurs 10 times
05 Array2 PIC X(9), which occurs 20 times
51. What object-oriented features does COBOL language provide?
Object-Oriented COBOL has the following advantages:
52. What are some of the drawbacks of using an ordered sequential file?
Records are arranged according to some key field in an ordered sequential file (s). All operations, such as adding or deleting, should be performed per a specific field order. Adding, updating, or deleting records within a new file is the only way to achieve this goal while maintaining the file’s order. Because they all occur on the disc, the time it takes to access data is the primary stumbling block in processing any feature. This slows down the system and reduces computation speed if we use ordered sequential files when they are not necessary.
We see that these are the top 50 COBOL interview questions asked during interviews. These questions have been framed after thorough research and going through various COBOL interview questions asked in written tests. If a candidate goes through all these questions, then he or she can easily crack any COBOL-related interviews.
If you are interested in making a career in the Data Science domain, our 11-month in-person Postgraduate Certificate Diploma in Data Science course can help you immensely in becoming a successful Data Science professional.