Are you a candidate? Complete list of COBOL interview questions ๐Ÿ‘‡

Index

General

  1. What will happen if you code GO BACK instead of STOP RUN in a stand alone COBOL program?
  2. What is the IS NUMERIC clause?
  3. What is the difference between Call and a Link?
  4. What are literals?
  5. Can you call an OS VS COBOL pgm from a VS COBOL II pgm?
  6. How can arrays be defined in COBOL?
  7. Explain the terms Static Linking and Dynamic Linking.
  8. What do you do to resolve SOC-7 error?
  9. What Is An In Line Perform? When Would You Use It?
  10. What is the difference between Global and External Variables?
  11. What is the Purpose of Pointer in the string?
  12. What is the function of REPLACING in a COPY statement?
  13. What is the use of the IS NUMERIC clause?
  14. What Is The Difference Between Pic 9.99 And 9v99?
  15. How can you differentiate between a binary search and a sequential search?
  16. What Is The Difference Between Index And Subscript?
  17. Explain the function of EVALUATE statement in COBOL.
  18. What Is Redefines Clause?
  19. What do you understand by index and subscript?
  20. What Divisions, Sections And Paragraphs Are Mandatory For A Cobol Program?
  21. How Is Sign Stored In A Comp-3 Field?
  22. Why does the file always need to be opened in I-O mode for REWRITE purposes?
  23. A table has two indexes defined. Which one will be used by the SEARCH?
  24. How can you tell if a module is being called Dynamically or Statically?
  25. What are some characteristics of COBOL as means of business language?
  26. What are the data types that COBOL supports?
  27. Our program has an array defined to have 10 items. Due to a bug, We find that even if the program access the 11th item in this array, the program does not abend. What is wrong?
  28. What do you understand by PSB and ACB?
  29. Explain the difference between Subscript and Index.
  30. Which type of error is trapped by ON SIZE ERROR option?
  31. Can you REWRITE a record in an ESDS file? Can you DELETE a record from it?
  32. What are divisions in a COBOL program?
  33. What are the different rules of SORT operation?
  34. What is the difference between SSRANGE and NOSSRANGE?
  35. What is the difference between Perform With Test After and Perform With Test Before?
  36. What do you understand by passing by reference and passing by content?
  37. What is the difference between CONTINUE & NEXT SENTENCE?
  38. When Would You Use In-line Perform?
  39. What Is File Status 39?
  40. What do you do to resolve SOC-7 error?
  41. What are Advantages Of Redefines Clause?
  42. In An Evalute Statement Is The Order Of The When Clauses Significant?
  43. Which mode is used to operate the sequential file?
  44. Where can we specify OCCURS clause?
  45. Explain what you understand by passing BY VALUE.
  46. What is the difference between NEXT SENTENCE & CONTINUE?
  47. What Is The Importance Of Global Clause According To New Standards Of Cobol?
  48. What is the point of the REPLACING option of a copy statement?
  49. What should be the sorting order for SEARCH ALL?
  50. What are the guidelines to write a structured COBOL program?
  51. If You Were Passing A Table Via Linkage, Which Is Preferable - A Subscript Or An Index?
  52. What is the role of ACCEPT?
  53. What are the differences between Structured COBOL Programming and Object-Oriented COBOL programming?
  54. What are the modes of File opening in COBOL?
  55. Explain an in-line PERFORM?
  56. When is a scope terminator mandatory?
  57. What is length in COBOL?
  58. In The Jcl, How Do You Define The Files Referred To In A Subroutine?
  59. How to remove the spaces at the end of each record in the output file of variable length, via COBOL program?


The Questions
General
1. What will happen if you code GO BACK instead of STOP RUN in a stand alone COBOL program? โ†‘

A Stop run ends the unit of work and returns control to the operating system whereas GOBACK returns control to calling program. So if we code GO BACK instead of Stop Run, it will go in infinite loop.

2. What is the IS NUMERIC clause? โ†‘

The IS NUMERIC clause is used to check if an item is numeric or not. The value returned will be TRUE if the item that is checked for contains only numbers whether positive or negative.

3. What is 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.

4. What are literals? โ†‘

A literal is a data item which consists value by itself. It cannot be referred by a name. They are constant data items. There are two types of literals:

  • String / Alphanumeric Literals
  • Numeric Literals
5. Can you call an OS VS COBOL pgm from a VS COBOL II pgm? โ†‘

In non-CICS environment, it is possible. In CICS, this is not possible.

6. How can arrays be defined in COBOL? โ†‘

Arrays can be defined as:

  • 05 Array2 PIC X(9) which occurs 20 times
  • 05 Array 1 PIC X(9) which occurs 10 times
7. Explain the terms Static Linking and Dynamic Linking. โ†‘

In Static linking, the subroutine links into the calling program whereas in Dynamic linking, the key program and subroutine will remain as separate modules. Static linking and Dynamic linking can be attained by link edit options- DYNAM or NODYNAM.

8. What do you do to resolve SOC-7 error? โ†‘
  • Offending data need to be corrected
  • The main cause for SOC-7 error is un-initialized numeric item. Focus on examining on this.
  • Lot of installations provide a dump for run time abends, and these abends provide the offset which is returned by the last instruction where the abend occurred.
  • Focus on examining the compilation output XREF listing to find the verb and the line number within the source code at this offset.
  • Later investigate the source code for finding the bug
  • Define certain datasets(SYSABOUT etc) in JCL, for capturing runtime dumps
  • At times few installations might have batch program debugging tool. Utilize them to resolve the issue.
9. What Is An In Line Perform? When Would You Use It? โ†‘

The PERFORM and END-PERFORM statements bracket all COBOL II statements between them. The COBOL equivalent is to PERFORM or PERFORM THRU a paragraph. In line PERFORMs work as long as there are no internal GO TOs, not even to an exit. The in line PERFORM for readability should not exceed a page length - often it will reference other PERFORM paragraphs.

10. What is the difference between Global and External Variables? โ†‘

Global variables are accessible only to the batch program whereas external variables can be referenced from any batch program residing in the same system library.

11. What is the Purpose of Pointer in the string? โ†‘

The Purpose of Pointer is to specify the leftmost position within receiving field where the first transferred character will be stored.

12. What is the function of REPLACING in a COPY statement? โ†‘

REPLACING allows for the same copy to be repeated more than once in the same code just by replacing the value.

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

14. What Is The Difference Between Pic 9.99 And 9v99? โ†‘

PIC 9.99 is a FOUR-POSITION field that actually contains a decimal point where as PIC 9v99 is THREE- POSITION numeric field with implied or assumed decimal position.

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

16. What Is The Difference Between Index And Subscript? โ†‘

Subscript refers to the array occurrence while index is the displacement (in no of bytes) from the beginning of the array. An index can only be modified using PERFORM, SEARCH & SET. Need to have index for a table in order to use SEARCH, SEARCH ALL.

17. Explain the function of EVALUATE statement in COBOL. โ†‘

EVALUATE statement does the same job of a CASE statement or a nested-IF statement. The main difference between EVALUATE and nested-IF is that โ€œbreakโ€ is not needed for the former and the control leaves the EVALUATE statement once a match is found.

18. What Is Redefines Clause? โ†‘

Redefines clause is used to allow the same storage allocation to be referenced by different data names.

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

20. What Divisions, Sections And Paragraphs Are Mandatory For A Cobol Program? โ†‘

IDENTIFICATION DIVISION and PROGRAM-ID paragraph are mandatory for a compilation error free COBOL program.

21. How Is Sign Stored In A Comp-3 Field? โ†‘

It is stored in the last nibble. For example if your number is +100, it stores hex 0C in the last byte, hex 1C if your number is 101, hex 2C if your number is 102, hex 1D if the number is -101, hex 2D if the number is -102 etc.

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

23. A table has two indexes defined. Which one will be used by the SEARCH? โ†‘

The index named first can be used by search.

24. How can you tell if a module is being called Dynamically or Statically? โ†‘

The ONLY way is to look at the output of the linkage editor (IEWL) or the load module itself. If the module is being called DYNAMICALLY then it will not exist in the main module, if it is being called STATICALLY then it will be seen in the load module. Calling a working storage variable, containing a program name, does not make a DYNAMIC call. This type of calling is known as IMPLICITE calling as the name of the module is implied by the contents of the working storage variable. Calling a program name literal.

25. What are some characteristics of COBOL as means of business language? โ†‘

COBOL is a dominant programing language that has aided business users for a few decades. Following are the features of COBOL as a means of business language:

  • It can be compiled, executed and brought together on various machines.
  • It can handle large volumes of data and it is a business-oriented application.
  • It offers several debugging and testing tools for business users as it has several versions that make it easy to debug.
  • It is a structured language.
26. What are the data types that COBOL supports? โ†‘

COBOL supports 3 different data types- Alphanumeric (X), Alphabetic(A) and Numeric(9).

27. Our program has an array defined to have 10 items. Due to a bug, We find that even if the program access the 11th item in this array, the program does not abend. What is wrong? โ†‘

Must use compiler option SSRANGE if you want array bounds checking. Default is NOSSRANGE.

28. What do you understand by PSB and ACB? โ†‘

PSB: - PSB stands for Program specification block. - This block is used to define how any program is to access an IMS DB. The PSB comprises of the PCB (Program Communication Block). - Each PSB must contain at least one PCB. These contain information such as which segment in DB can be accessed, what the program can do and how the DB can be accessed.

ACB: - ASB stands for Access control blocks. - Basically they are a block of memory with information stored in them. These are generated by IMS. - They serve the purpose of being an expansion of the information contained in the PSBs. By doing so they speed up the access to the applicable DSDs. IMS builds the ACB with the ACBGEN utility by merginf info from PSB and the DBD. - They can be built either dynamically or can be prebuilt.

29. Explain the difference between Subscript and Index. โ†‘

Subscript refers to the occurrence in an array whereas Index refers to the number of bytes or displacement from the beginning of the array.

An Index can be modified only with PERFORM, SEARCH and SET commands.

The index is needed to perform SEARCH or SEARCH ALL in a Table.

30. Which type of error is trapped by ON SIZE ERROR option? โ†‘

ON SIZE ERROR option is raised when there is:

  • Division by 0
  • Zero raised to a negative number
  • A negative number raised to a fractional power
  • Fixed point overflow
  • Zero raised to zero power
31. Can you REWRITE a record in an ESDS file? Can you DELETE a record from it? โ†‘

Can rewrite(record length must be same), but not delete.

32. What are 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.

33. What are the different rules of SORT operation? โ†‘

SORT can be performed when

  • Input and Output files must remain closed
  • Working file must have a select clause
  • Input and Output files have FD entries
  • Work file should have short description in File Section
34. 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.

35. What is the difference between Perform With Test After and Perform With Test Before? โ†‘

If TEST BEFORE is specified, the condition is tested at the beginning of each repeated execution of the specified PERFORM range. If TEST AFTER is specified, the condition is tested at the end of each repeated execution of the PERFORM range. The range is executed at least once in TEST AFTER.

36. What do you understand by passing by reference and passing by content? โ†‘

Passing by reference: - When between programs data is shared or passed the subprogram always refers and processes the data items within the calling programs storage. - It does not work on the copy of the data. Whenever a call by reference identifier is used the caller and the called share the same memory.

Passing by content: - In this case the calling program only passes the contents of the identifier or the literal. - When this is used the called program is unable to change the value of the identifier or the literal in the program being called. Further it cannot change the value even if it has modified the variable through which it received its literal.

37. What is the difference between CONTINUE & NEXT SENTENCE? โ†‘

CONTINUE is like a null statement (do nothing) , while NEXT SENTENCE transfers control to the next sentence (!!) (A sentence is terminated by a period)

38. When Would You Use In-line Perform? โ†‘

When the body of the perform will not be used in other paragraphs. If the body of the perform is a generic type of code (used from various other places in the program), it would be better to put the code in a separate para and use PERFORM paraname rather than in-line perform.

39. What Is File Status 39? โ†‘

Mismatch in LRECL or BLOCKSIZE or RECFM between your COBOL pgm & the JCL (or the dataset label). You will get file status 39 on an OPEN.

40. What do you do to resolve SOC-7 error? โ†‘

Basically you need to correct the offending data.

Many times the reason for SOC7 is an un-initialized numeric item. Examine that possibility first.

Many installations provide you a dump for run time abends ( it can be generated also by calling some subroutines or OS services thru assembly language). These dumps provide the offset of the last instruction at which the abend occurred. Examine the compilation output XREF listing to get the verb and the line number of the source code at this offset. Then you can look at the source code to find the bug. To get capture the runtime dumps, you will have to define some datasets (SYSABOUT etc ) in the JCL.

If none of these are helpful, use judgement and DISPLAY to localize the source of error.

Some installation might have batch program debugging tools. Use them.

41. What are Advantages Of Redefines Clause? โ†‘
  • You can REDEFINE a Variable from one PICTURE class to another PICTURE class by using the same memory location.
  • By REDEFINES we can INITIALISE the variable in WORKING-STORAGE Section itself.
  • We can REDEFINE a Single Variable into so many sub variables. (This facility is very useful in solving Y2000 Problem.)
42. In An Evalute Statement Is The Order Of The When Clauses Significant? โ†‘

Yes. Evaluation of the WHEN clauses proceeds from top to bottom and their sequence can determine results.

43. Which mode is used to operate the sequential file? โ†‘

An O-I mode (Output/Input mode) is used for starting and initiation of processing files. Processing of files is determined by successful execution of an OPEN statement.

44. Where can we specify OCCURS clause? โ†‘

In array declaration, we can specify occurs clause on Elementary item as well as on Group item also.

45. Explain what you understand by passing BY VALUE. โ†‘

It means that the program/method passes the value of the identifier or literal. It does not imply a reference to the sending data item. The program/method called has the capability to change the parameter in the called/invoked program/method. But there is no effect on the argument value in the calling program as the subprogram/method has access to a temporary copy of the sent data item. The parameters used should always be of a particular defined data type in case the data is to be passed somewhere else. This is different as compared to BY CONTENT as it does not passes only the contents of the identifier.

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

47. What Is The Importance Of Global Clause According To New Standards Of Cobol? โ†‘

When any data name, file-name, Record-name, condition name or Index defined in an Including Program can be referenced by a directly or indirectly in an included program, Provided the said name has been declared to be a global name by GLOBAL Format of Global Clause is01 data-1 pic 9(5) IS GLOBAL.

48. What is the point of the REPLACING option of a copy statement? โ†‘

REPLACING allows for the same copy to be used more than once in the same code by changing the replace value.

49. What should be the sorting order for SEARCH ALL? โ†‘

It can be either ASCENDING or DESCENDING. ASCENDING is default. 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).

50. What are the guidelines to write a structured COBOL program? โ†‘

There is a format that has to be taken care of while writing a structured COBOL program. One has to work within these guidelines to make a structured COBOL-

  • In order to construct a case, one has to use EQUIVALENT statements every time.
  • Scope terminators are used for nesting.
  • IN-LINE PERFORM statements are used for writing โ€˜doโ€™ constructions. Also, use Tests before and Test after in performing statements while writing do-while statements.
51. If You Were Passing A Table Via Linkage, Which Is Preferable - A Subscript Or An Index? โ†‘

It is not possible to pass an index via linkage. The index is not part of the calling programs working storage.

52. What is the role of ACCEPT? โ†‘

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.

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

54. What are the modes of File opening in COBOL? โ†‘

The modes of opening a file in COBOL are OUTPUT, INPUT, I/O and EXTEND.

What is the extreme size of a mimetic field that can be defined in COBOL?

The maximum size of a numeric field that can be defined in COBOL is PIC 9(18).

55. Explain 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.

56. When is a scope terminator mandatory? โ†‘

Scope terminators are mandatory in COBOL in in-line PERFORMS and EVALUATE statements. For ease of reading, it is suggested coding practice to always make scope terminators explicit.

57. What is length in COBOL? โ†‘

Length is like a particular record to have the extent of a group or a simple item.

58. In The Jcl, How Do You Define The Files Referred To In A Subroutine? โ†‘

Supply the DD cards just as you would for files referred to in the main program.

59. How to remove the spaces at the end of each record in the output file of variable length, via COBOL program? โ†‘

Spaces at the end of the record are called trailing spaces. There are no functions to trim the trailing space. It can be done by altering the RECORD-LENGTH.

The following is the accomplish this task: 1. Assuming that a variable length file has maximum record length as 4000. 2. Move the original record length value to RECORD-LENGTH. This process enables the trimming off the entire record that is beyond the length. 3. In case the data is populated only up to 3000 bytes. Then move 3000 to RECORD-LENGTH. 4. By implementing the above process, the record would trim off the trailing 1000 bytes.