COBOL or Common Business Oriented Language is an English like compiled programming language used mainly for business COBOL Interview questions with answers will help you prepare for technical interviews and online selection tests during campus placement for freshers and job interviews for professionals.
1. What is the distinction among INCLUDE and COPY?
Answer: They both help to expand variables/codes in a program. The critical difference is INCLUDE gets extended at PRE-COMPILATION & COPY expands during compilation time. DB2 pre-compiler can’t process COPY statements, not it connect to DB2 directories to validate the Table Attributes (Columns, Name, Data Type) and thus the DCL statements embedded in INCLUDE.
2. State the difference between GOBACK, STOP RUN and EXIT PROGRAM in COBOL?
Answer: The fundamental differences between GOBACK, STOP RUN, and EXIT PROGRAM in COBOL are:
• GOBACK returns control to the calling program
• STOP RUN stops the present work unit and returns control to OS
• EXIT PROGRAM is utilized to leave a program that has been called by another program
3. Define DELIMITED BY SPACE and DELIMITED BY SIZE along with their utilization?
Answer: DELIMITED BY SPACE or DELIMITED BY SIZE will be utilized alongside the STRING for controlling the information in case it is replicated.
• DELIMITED BY SIZE: Total size of information things would be considered as the delimiter,
• DELIMITED BY SPACE: Space would be considered as the delimiter
4. What are various search techniques in COBOL? Explain. What is the difference between SEARCH and SEARCH ALL?
Answer: There are 2 searching techniques in COBOL.
Serial search: SEARCH
• It is a process of finding a particular value in a given list.
• The search is implemented by checking each element in the list, one at a time and in sequence.
• This process is continued until the desired element is found.
• SEARCH is used for serial search.
Binary Search: SEARCH ALL
• It is a process of finding a particular element in a sorted list.
• The binary search starts by comparing the middle element of the array.
• The comparison determines the element’s location – either in the first half of the list or in the second half of the list.
• This process continues until the search element is equal to the middle element of the list
• SEARCH ALL is used for binary search.
• The list must be sorted by using the ASCENDING / DESCENDING KEY clause, which loads.
• The default key is ASCENDING KEY.
5. What is the difference between a binary search and a sequential search?
Answer: In a binary search, the table element key values will be in ascending or descending sequence. The table is ‘halved'(Divided into two) 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 the elements do not have to be in a specific sequence.
The binary search is much faster for more tables, while sequential Search works well with lesser ones. SEARCH ALL is used for binary search; SEARCH for sequential search.
6. What is SOC-7 abend? What do you do to resolve SOC-7 error?
Answer: Many times the reason for SOC7 is an un-initialized numeric item.
a. Offending data need to be corrected, focus on examining this.
b. A 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.
c. Focus on examining the compilation output XREF listing to find the verb and the line number within the source code at this offset.
d. Later investigate the source code for finding the bug.
e. Define certain datasets(SYSABOUT etc) in JCL, for capturing runtime dumps.
f. At times few installations might have batch program debugging tool. Utilize them to resolve the issue.
7. What is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY)?
Answer: These are the options of compile/link editing:
AMODE: Addressing Mode.
• AMODE(24): It is a 24-bit addressing mode.
• AMODE(31): It is a 31-bit addressing mode.
• AMODE(ANY): Either 24 bit or 31-bit address mode depending upon RMODE.
RMODE: Resident mode.
• RMODE(24): It resides within virtual storage below 16 Meg line.
a. Programs of 31 bit which call 24-bit programs are preferred to use this mode.
b. RMODE(ANY): Either 24 bit or 31-bit address mode depending upon RMODE.
c. OS/VS COBOL program uses 24-bit address only.
• RMODE(ANY): This mode can reside below or above 16 Meg line.
8. Explain what you understand by passing BY VALUE.
Answer: 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.
9. What do you understand by passing by reference and passing by content?
Answer: 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.
10. State the various causes of S0C1, S0C5, and S0C7.
Answer: S0C1 can be caused due to:
• A misspelled DD name.
• Read/Write to a dataset that is unopened.
• The subprogram called cannot be found.
• Read to the dataset for an opened output.
S0C5 can be caused due to:
• A bad or damaged Subscript/index.
• An incorrect exit from a preform.
• The I/O area is accessed before reading.
• An unopen dataset is closed.
S0C7 can be caused due to:
• A numeric operation is performed in a non-numeric data.
• Working storage is un-initialized.
• Excess coding past the max permitted dub script.
11. What is the difference between subscript and index?
Answer: Subscript refers to the occurrence of an array but the Index is the displacement from the beginning of the array. An index can only be modified using PERFORM, SEARCH & SET. Need to have indexed for a table in order to use SEARCH, SEARCH ALL.
12. What is the difference between performing a SECTION and a PARAGRAPH?
Answer: SECTION will have all the paragraphs that are part of the section, to be performed. PARAGRAPH will have only that paragraph to be performed.
13. What is the difference between PERFORM … WITH TEST AFTER and PERFORM … WITH TEST BEFORE?
Answer: If the 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.
14. What is Static and Dynamic linking?
Answer: In static linking, called subroutine links into the calling program, while in dynamic linking, the subroutine & the main program will exist as separate modules. Dynamic and Static linking can be achieved by choosing either the DYNAM or NODYNAM link edit option.
A statically called subroutine will not be in its initial state the next time it is called unless you explicitly use INITIAL or you do a CANCEL.
A dynamically called routine will always be in its initial state.
15. What Is The Difference Between A Dynamic And Static Call In Cobol?
Answer: All called modules cannot run standalone if they require program variables passed to them via the LINKAGE section. Dynamically called modules are those that are not bound with the calling program at link-edit time (IEWL for IBM) and so are loaded from the program library (joblib or steplib) associated with the job. For DYNAMIC calling of a module the DYNAM compiler option must be chosen, else the linkage editor will not generate an executable as it will expect u address resolution of all called modules. A Statically called module is one that is bound with the calling module at link-edit and therefore becomes part of the executable load module.
16. How Can I Tell If A Module Is Being Called Dynamically Or Statically?
Answer: 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 call 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.
17. What kind of error is trapped by ON SIZE ERROR option?
Answer: ON SIZE ERROR option is raised when there is
• fixed-point overflow
• Zero raised to the zero power
• Division by 0
• Zero raised to a negative number
• A negative number raised to a fractional power.
18. What are an SSRANGE and NOSSRANGE?
Answer: These are options for a compiler to find the subscript out of range.
SSRANGE is a compiler option that handles the array overflow. SSRANGE also needs to be specified in COBOL programing language. These help in finding the subscript out of range.
NOSSRANGE is used for performance sensitive applications. NOSSRANGE is a default option that doesn’t support any runtime error if the index or subscript runs out of range.
19. My Program Has An Array Defined To Have 10 Items. Due To A Bug, I Find That Even If The Program Access The 11th Item In This Array, The Program Does Not Abend. What Is Wrong With It?
Answer: Must use compiler option SSRANGE if you want array bounds checking. Default is NOSSRANGE. If no options provided then it will abend with SOC4 -An Invalid address referenced due to subscript/index error.
20. What is the difference between the NEXT SENTENCE and CONTINUE in COBOL programing language?
Answer: In COBOL language, NEXT STATEMENT is used to give control to the next verb following the next period. Next Sentence is the collection of sentences that always ends with (.) so the control passes over to the next verb following the next period. When the NEXT SENTENCE is coded, 1 will not be added to input count.
CONTINUE statement is used to give control to the next verb after the explicit scope terminator. When CONTINUE is coded, +1 will be added to input count.
21. When would you use in-line perform?
Answer: 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 para name rather than in-line perform.
22. How is sign stored in Packed Decimal fields and Zoned Decimal fields?
Answer: Packed Decimal fields: Sign is stored as a hex value in the last nibble (4 bits ) of the storage.
Zoned Decimal fields: As a default, sign is overpunched with the numeric value stored in the last bite.
23. What is the difference between CONTINUE and NEXT SENTENCE?
Answer: CONTINUE transfers the control to the next statement after the scope terminator, it’s like a null statement. NEXT SENTENCE transfers the control to the statement after the first period is encountered.
24. What Is Comp Sync?
Answer: Causes the item to be aligned on natural boundaries. Can be SYNCHRONIZED LEFT or RIGHT.
For binary data items, the address resolution is faster if they are located at word boundaries in the memory. For example, on main frame the memory word size is 4 bytes. This means that each word will start from an address divisible by 4. If my first variable is x(3) and next one is s9(4) comp, then if you do not specify the SYNC clause, S9(4) COMP will start from byte 3 ( assuming that it starts from 0 ). If you specify SYNC, then the binary data item will start from address 4. You might see some wastage of memory, but the access to this computational field is faster.
25. Why Do We Code S9 (4) Comp. Inspite Of Knowing Comp-3 Will Occupy Less Space ?
Answer: Here S9(4) comp is a small integer, so two words equal to 1 byte so totally it will occupy 2 bytes(4 words). In s9(4) comp-3 as one word is equal to 1/2 byte.4 words equal to 2 bytes and sign will occupy 1/2 byte so totally it will occupy 3 bytes.
26. What Care Has To Be Taken To Force Program To Execute Above 16 Meg Line?
Answer: Make sure that link option is AMODE=31 and RMODE=ANY. Compile option should never have SIZE (MAX). BUFSIZE can be 2K, efficient enough.
27. What is a reentrant program? How will you make a program Reentrant?
Answer: A reentrant program, while being executed resides in the common virtual area so that one copy of it may be shared among all callers. Use RENT compiler option.
28. What are the steps you go through while creating a COBOL program executable?
Answer:DB2 pre-compiler (if embedded SQL is used), CICS translator (if CICS program), Cobol compiler, Link editor. If DB2 program, create plan by binding the DBRMs.
29. How will you count the number of characters in a null-terminated string?
Answer: MOVE 0 TO char-count
INSPECT null-terminated-string TALLYING char-count FOR CHARACTERS BEFORE X”00″
30. What are the causes for S0C1, S0C4, S0C5, S0C7, S0CB abends
Answer: S0C1 – Maybe due to
1.Missing or misspelled DD name
2.Read/Write to the unopened dataset
3. Read to dataset opened the output
4. Write to dataset opened input
5. Called subprogram not found.
S0C4 may be due to
1.Missing Select statement(during compile)
2.Bad Subscript/index
3.Protection Exception
4.Missing parameters on called subprogram
5.Read/Write to unopened file
6.Move data from/to unopened file.
S0C5 May be due to
1.Bad Subscript/index
2.Close an unopen dataset
3.Bad exit from a perform
4.Access to I/O area(FD) before read.
S0C7 may be due to
1.Numeric operation on non-numeric data
2.Un-initialize working-storage
3.Coding past the maximum allowed sub script.
S0CB may be due to Division by Zero
31. What will happen if you code GO BACK instead of STOP RUN in a stand-alone COBOL program i.e. a program which is not calling any other program?
Answer: Both give the same results when a program is not calling any other program. GO BACK will give control to the system even though it is a single program.
32. what is the difference between external and global variables?
Answer: 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.
33. Give some advantages of REDEFINES clause.
Answer: You can REDEFINE a Variable from one PICTURE class to another PICTURE class by using the same memory location. By REDEFINES we can INITIALIZE 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 Y2K Problem.)
34. What is PERFORM ? What is VARYING ? (More details about these clauses)
Answer: The PERFORM statement is a PROCEDURE DIVISION statement which transfers control to one or more specified procedures and controls as specified the number of times the procedures are executed. After execution of the specified procedures is completed (i.e., for the appropriate number of times or until some specified condition is met), control is transferred to the next executable statement following the PERFORM statement. There are 5 types of PERFORM statements:
• Basic PERFORM
• PERFORM TIMES
• PERFORM UNTIL
• PERFORM VARYING
• IN-LINE PERFORM
35. Can JUSTIFIED be used for all the data types?
Answer: No, it can be used only with alphabetic and alphanumeric data types.
36. Why occurs cannot be used in 01 level ?
Answer: Because, Occurs clause is there to repeat fields with same format, not the records.
37. What is the function of REPLACING in a COPY statement?
Answer: REPLACING allows for the same copy to be repeated more than once in the same code just by replacing the value.
Syntax: COPY REPLACING BY
38. How do you reference the following file formats from COBOL programs?
Answer: Fixed Block File – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0 .
Fixed Unblocked – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, do not use BLOCK CONTAINS
Variable Block File – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, BLOCK CONTAINS 0. Do not code the 4 bytes for record length in FD ie JCL rec length will be max rec length in pgm + 4 Variable Unblocked – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, do not use BLOCK CONTAINS. Do not code 4 bytes for record length in FD ie JCL rec length will be max rec length in pgm + 4.
ESDS VSAM file – Use ORGANISATION IS SEQUENTIAL.
KSDS VSAM file – Use ORGANISATION IS INDEXED, RECORD KEY IS, ALTERNATE RECORD KEY IS
RRDS File – Use ORGANISATION IS RELATIVE, RELATIVE KEY IS
Printer File – Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0. (Use RECFM=FBA in JCL DCB).
39. What is file status 39 and 92?
Answer: 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.
File Status 92 – Logic error. e.g., a file is opened for input and an attempt is made to write to it.
DB2 Interview Questions with Answer : Click Here
IBM Reference: Click Here
A well-maintained product backlog is crucial for successful product development. It serves as a single…
Incremental value to the customer refers to the gradual delivery of small, functional parts of…
A Product Market refers to the group of potential customers who might be interested in…
The Professional Agile Leadership - Evidence-Based Management (PAL-EBM) certification offered by Scrum.org is designed for…
The Professional Agile Leadership (PAL I) certification, offered by Scrum.org, is designed to equip leaders…
Choosing the right Scrum Master Certification depends on your current experience and career goals. If…