Real Time Interview Questions


Introduction -

What is the history of COBOL programming language?

COBOL is a high-level programming language initially developed by the CODASYL Committee in the early 1960s.

  • First COBOL Compiler - CODASYL developed in the early 1960s and assigned to the ANSI for improvements. The addressing mode feature of AMODE 16 (16-bit).
  • ANSI COBOL 1968 - ANSI developed a standard form of the language in 1968 to overcome incompatibility between different versions and called it as ANS COBOL.
  • COBOL 1974 (OS/VS COBOL) - ANSI published a revised version of (ANS) COBOL, which contains an additional set of features. The addressing mode feature of AMODE 24 (24-bit).
  • VS COBOL II (1988) - ANSI published another revised version with new features like scope terminators, including END-IF, END-PERFORM, END-READ, etc. The new feature of AMODE 31 (31-bit).
  • Enterprise COBOL 2002 and object-oriented COBOL - IBM, Fujitsu, and Micro Focus were involved in developing object-oriented syntax and introduced object-orientation features. It was approved by the ISO and published in late 2002.
  • Enterprise COBOL v4.1 (2007) - COBOL 2002 suffered from poor support, and no compilers completely supported the object-oriented standard. So the most popular revised version was developed and released with the standard compiler's support in 2007.
  • Enterprise COBOL v6.3 (2019) - It is developed with AMODE (64-bit), UTF-8, intoduces some new compiler options.
  • Enterprise COBOL v6.4 (2022) - Enterprise COBOL 6.4 is the current version and developed with COBOL/Java interoperability, interoperability between AMODE 31 (31-bit) and AMODE 64 (64-bit)

What are the differences between OS COBOL and VS COBOL II?

OS COBOLVS COBOL II
Runs in 24-bit addressing mode31-bit addressing mode introduced. Runs either in 24-bit or 31-bit addressing modes
Supports Report WriterDoes not support Report Writer
USAGE IS POINTER is not supportedUSAGE IS POINTER is supported
Reference modification is not supportedReference modification is supported
EVALUATE is not supportedEVALUATE is supported
Scope terminators are not supportedScope terminators are introduced
Follows ANSI 74 standardsANSI 85 standards are followed
Calls between programs are not supported under CICSCalls between programs are supported under CICS

What is the difference between VS COBOL and enterprise COBOL?

Structured COBOLObject-Oriented COBOL
It follows procedural programming, breaking down programs into smaller, manageable procedures or modulesIt utilizes OOP principles such as encapsulation, inheritance, and polymorphism
It typically employs a top-down design approach, where the main program calls subprograms or modules sequentiallyPrograms are designed around classes and objects, allowing for better organization and encapsulation of data and methods
The level of code reusability is limitedIt promotes higher code reusability through the creation of reusable classes and inheritance, enhancing modularity and maintainability
Less secure as there is no data hiding feature involvedIt follows an object-oriented approach, there is encapsulation and abstraction involved which helps in data hiding
More natural way of codingObjects are first identified and functionalities of those are then written. Hence, it is more secure.

What is the difference between VS COBOL and enterprise COBOL?

VS COBOLEnterprise COBOL
It supported the 68 COBOL Standard and the 74 COBOL StandardIt supports the 85 COBOL Standard
Undocumented OS/VS COBOL extensions supportedUndocumented OS/VS COBOL extensions not supported

Features -

What are the main features of COBOL?

The main features of the COBOL language are -

  • COBOL is simple
  • Standard Language
  • COBOL is stable
  • Business Oriented
  • Structured
  • Robust
  • Easy to read
  • Easy to Learn
  • Self-documenting

Basic Verbs -

What is a word, variable, literal, constant and comment in COBOL?

A COBOL word is a set of characters, and each character is from the character set - A to Z, 0 to 9, - (hyphen), _ (underscore).

A Variable is used to store and process the value. A Variable is also called a data item. For Example - WS-A, WS-VAR, WS-TOTAL, WS-INPUT, WS_OUTPUT, etc.

The literal is the value that is assigned to the variable.

A variable is initialized with a literal. If the variable value doesn't change during the program's execution, the variable is considered as a constant variable, and the value is considered as a constant value.

A comment is a non-executable statement that provides the information about code or business requirements.

Program Structure -

Explain the COBOL Program Structure?

COBOL program structure is a top-to-bottom hierarchical design, consisting of Divisions, Sections, Paragraphs, Sentences, Statements, and Character strings.

What is the difference between performing a Statement and a Sentence?

StatementSentence
A COBOL statement is a combination of COBOL keywords and operands. A sentence is a sequence of two or more statements ended by a period (.).
All statements should mark with a explicit scope terminator (period - .) at the end. It provides a way to group related statements together, and the explicit scope terminator (period) indicates the end of the sentence.

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

SECTIONPARAGRAPH
A paragraph is a block of code consisting of one or more sentences or statements. A section is a collection of one or more related paragraphs within the PROCEDURE DIVISION.
A paragraph coding begins with the paragraph name and ends when any of the following meets - scope terminator of the same paragraph, starting of another paragraph, beginning of the new section and the program ends. It ends at another section starting or ending the program.

Divisions -

What is a significance of division?

A division is a collection of one or more sections and paragraphs. Division begins with the division name and ends at the beginning of the subsequent division or the program ends.

What are the four divisions in COBOL?

COBOL has 4 system-defined divisions. They are -

  • IDENTIFICATION DIVISION
  • ENVIRONMENT DIVISION
  • DATA DIVISION
  • PROCEDURE DIVISION

What divisions, sections and paragraphs are mandatory in a COBOL program?

Below are mandatory in COBOL programs -

  • IDENTIFICATION DIVISION, PROGRAM-ID paragraph
  • PROCEDURE DIVISION

What is the purpose of a program-id in COBOL? What is length of the program name in program-id?

PROGRAM-ID entry is used to specify the program name. It is mandatory and should be the first entry in the IDENTIFICATION DIVISION.
The program name can be up to 30 characters in length.

What is the significance of DEBUGGING MODE with SOURCE-COMPUTER?

It activates a compile-time debugging switch for debugging lines coded in the program.

How to enable or disable the debugging lines in COBOL program?

If SOURCE-COMPUTER WITH DEBUGGING MODE is coded, the program recognizes the statements with 'D' in the 7th column as part of the code. This enables the debugging mode in the program.

If SOURCE-COMPUTER WITH DEBUGGING MODE is not coded, the program doesn't recognize the statements with 'D' in the 7th column as a part of the code. This disables the debugging mode in the program.

What makes a LINKAGE SECTION necessary?

It declares the variables used to pass data between COBOL programs or receive data from run JCL.

What is the use of PROCEDURE DIVISION? Why it is required?

The actual logic will be written in PROCEDURE DIVISION, which is responsible for carrying out the data processing tasks. Program execution starts from PROCEDURE DIVISION and ends with STOP RUN or GO BACK statements.

This is required to start the execution of the program to complete the task.

Coding Sheet -

What is the layout in COBOL?

COBOL coding sheet specifies from where each statement coding should start and how it differentiates from other statements.

Define the importance of understanding the coding standards used in COBOL programs?

Understanding coding standards in COBOL is important because it provides guidelines for writing code consistently and clearly. Following these standards helps programmers and teams work together more effectively, makes code easier to read and maintain, reduces errors, and ensures that programs meet quality and reliability requirements.

Level Numbers -

What is the significance of level numbers in COBOL?

Level numbers play the most important role in declaring the variables in the application programs. They specify the hierarchy or level of data items or variables.

Elementary items cannot be divided further. Level number, Data name, Picture clause and Value clause (optional) are used to describe an elementary item. State whether true or false?

False

What are the uses of 66, 77 and 88 levels?

Level number 66 is used to create another logical group by regrouping the elementary variables of a group. RENAMES keyword is used along with the 66-level number to rename the group.

Variables have no immediate relationship to any other variables. Those variables are called Individual variables. Special purpose level number 77 is to declare individual variables.

88-level number provides a descriptive name for a condition. The name associated with 88 level numbers is called as Condition Name, and the variable with 88 level numbers attached to it is called as Conditional Variable.

What is the maximum size of a 01 level item in COBOL II?

16777215 bytes

Can I rename an X(100) group field with a field of X(200)?

No. Not possible.

Can I rename an X(200) group field with a field of X(100)?

Yes

Variable | Data item -

How would you declare variables in COBOL?

For Example - Declaring a variable of numeric type to store a value 123.

 01 WS-NUMERIC-VAR      PIC 9(03) VALUE 123.
  • level-number - Refers the level number. From the example, it is 01.
  • variable-name - Refers the name of the variable. From the example, it is WS-NUMERIC-VAR.
  • data-type-character - Refers the type of the variable. From the example, it is numeric(9).
  • variable-length - Refers the variable length. From the example, it is 03.
  • literal-value - Refers the initial value assigned to the variable. From the example, it is 123.

How do you declare VARCHAR(25) In COBOL?

01 WS-VAR PIC X(25).

What is the maximum number of characters that can be used in variable names in COBOL?

30

PICTURE Clause -

What are the four categories of insertion in a picture clause? Explain?

  • Simple insertion - It involves inserting character(s) like blank, 0, /, and space in the PICTURE string while displaying for better readability.
  • Special insertion - It is used to insert the decimal-point while displaying the decimal values of a variable.
  • Fixed insertion - It is used to insert fixed characters (-, +, CR, DB, and $) into a numeric edited item.
  • Floating insertion - It is used for formatting numeric variables, mainly when dealing with currency values.

Define suppression or replacement in a picture clause?

It involves omitting leading zeros from a number, and replacement editing involves replacing leading zeros with a space or asterisk.

Data Types -

What is meant by data type in COBOL? What are they?

A data type defines the kind of data a variable can hold, such as numeric values, alphabetic characters, or alpha-numeric strings. There are five data types in COBOL, and those are -

  • Alphabetic
  • Alpha-numeric
  • Numeric
  • Sign
  • Decimal Point

What is the use of the REDEFINES clause in COBOL, and how can it be used to share data between different data types?

REDEFINES defines a new variable for the existing variable, which means two variables share the same memory area.
It is a way to declare multiple variables for a single memory area in different ways based on the requirement.

How many bytes does a S9(7) and S9(7) SIGN...SEPARATE field occupy?

S9(7) - 7 bytes
S9(7) SIGN...SEPARATE - 8 bytes

Statement Categories -

How many types of statement categories? What are they?

All COBOL statements are divided into four categories based on their actions, and they are -

  • Imperative Statements - It is a procedural instruction specifying an action to be taken during the program's execution.
  • Conditional Statements - It tests a condition and then executes one or more statements based on the result of that condition.
  • Delimited scope statements - It marks the statement ending by specific keywords.
  • Compiler-directing statements - It provide instructions to the compiler about how to compile the source program.

Input Output Statements -

What are the different ways to receive the input to the program?

It has two different formats and those are -

  • Receiving input from JCL
  • Receiving system date-related information

What is the usage of WITH NO ADVANCING in DISPLAY statement?

If coded, the cursor does not move to a new line after displaying the content.

Data Movement Statements -

What is initialize clause in COBOL and what are the defaults values of various data types?

INITIALIZE sets all elementary variables under group variable with system-defined initial values based on their data types. Below are the default values according to the data types -

Data typeDefault value
NumericZEROES
Alphabetic, Alpha-numericSPACES

Can we move the data from smaller element to larger element?

Yes

Can we move the data from larger element to small element in COBOL?

Yes. But the excess data gets truncated.

What is SOC-7 abend? How do you resolve it?

Moving non numeric data to numeric variables causes SOC-7 abend.

Find out the compile listing that displays in the abend information. Find the near by statement of the compile listing. Check the declarations of the variables used in MOVE statement and use the compatible data types to resolve the issue.

Conditional Statements -

What is the difference between CONTINUE and NEXT SENTENCE?

CONTINUENEXT SENTENCE
It transfers the control to the immediate statement that comes next in the program flow. It transfers the control to the following COBOL statement immediately after the explicit scope terminator (period - '.') in the flow.
It is allowed to code only with conditional statements like IF, IF...ELSE and EVALAUTE. It is allowed to code only with conditional statements like IF, IF...ELSE and EVALAUTE.
It doesn't skips any statements. It skips the statements between NEXT SENTENCE and the explicit scope terminator (period—'.').

What is IF? What are the different IF statements?

IF statement validates a condition to get the truth value and executes the statements under IF when the condition is TRUE. IF statements are of three types based on their usage in the program -

  • Simple IF
  • IF...ELSE
  • Nested IF

How do you use the EVALUATE statement in COBOL, and what are the different types of conditions that can be evaluated?

EVALUATE validates multiple conditions at a time and controls the program flow. It is a shorter form for the nested IF...ELSE and simplifies the logic when multiple choices are available.

EVALUATE can be divided logically into the below types based on their usage in the program -

  • Simple EVALUATE
  • EVALUATE TRUE
  • EVALUATE with THRU
  • EVALUATE with grouping multiple WHEN conditions
  • EVALUATE...WHEN with combined conditions

Looping Statements -

How do you use the perform statement in COBOL? Its types?

PERFORM statement executes the statement block repeatedly. The repetitive execution can be conditional or unconditional. If any condition is coded with it, the statements block gets executed until the coded condition is true.

PERFORM statement is mainly two types at high level based on how it is coded to perform the task –

  • Inline PERFORM
  • Outline PERFORM

If you want to come out of PERFORM and how will you use GOTO in the execution?

GO TO transfers control to another part of the program, allowing the program to "jump" to a different paragraph or section. We need to use the condition validation before performing GO TO statement. Otherwise, first iteration itself has been broken.

Explain the variation between inline and outline perform?

Inline PERFORMOutline PERFORM
PERFORM 
   statements-block
END-PERFORM.
PERFORM paragraph-name|section-name.
The PERFORM statement executes the statements block that is coded inline (between PERFORM and END-PERFORM) The PERFORM statement executes statements block that are coded outline (in a separate paragraph or section outside of PERFORM).
This requires no seperate paragraph or section. It requires a separate paragraph or seection that needs to be coded with statements block.
Not required to transfer the control to paragraph or section. Control transfers to the paragraphs or sections
Scope terminator END-PERFORM is mandatory Scope terminator END-PERFORM is not required

How is PERFORM...WITH TEST AFTER different from PERFORM...WITH TEST BEFORE?

PERFORM...WITH TEST AFTERPERFORM...WITH TEST BEFORE
It tests the condition after executing the statements block. It tests the condition before executing the statements block.
Statements block gets executed once regardless of the condition truth value. It is default with PERFORM if not coded any.

Describe the distinction in COBOL between the PERFORM and CALL statements?

PERFORMCALL
It is used to execute a statement block repetitively until a specific condition is TRUE. It calls the sub program to complete the task.
Statements block resides within the program. Statements block is in the another program.

Which Search verb is equivalent to PERFORM...VARYING?

Simple SEARCH

Arithmetic Statements -

How do you use the GIVING clause in COBOL, and what is its purpose?

GIVING phrase specifies that the output variables are used to store the result and are not part of the inputs. It is used to seperate the output variables apart from input variables.

What is the use of the COMPUTE statement in COBOL, and how is it different from the MOVE and ADD statements?

COMPUTE statement can use all the arithmetic operators in a single expression.
MOVE statement use to move data from one source to other.
ADD statement to perform addition operation.

String Handling -

How do you handle character string in COBOL, and what are the different string manipulation verbs available?

String handling statements are used to handle and manipulate strings. These statements are essential for processing textual data, allowing for modifications, evaluations, and extractions of character data within a COBOL program. They are -

  • STRING
  • UNSTRING
  • INSPECT

Define DELIMITED BY SPACE and DELIMITED BY SIZE along with their utilization?

DELIMITED BY SPACE specifies the SPACE to place at the end of the source item.
DELIMITED BY SIZE it'll consider the entire variable and delimter will be placed at the end of the variable data.

What is the ON OVERFLOW phase usage in STRING | UNSTRING statement?

ON OVERFLOW specifies the statements block executed when the overflow occurs when strings are separated.

What is the purpose of the INSPECT verb in COBOL, and what are some common scenarios where it is used?

INSPECT statement analyzes, counts, or replaces specific character(s) within a string. It is flexible and provides a range of functions to help with string manipulations. It has four common scenarios -

  • Counting number of characters
  • Replacing the characters
  • Counting and replacing characters
  • Converting characters

What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. INSPEXAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-CNT    PIC 9(02) VALUE 0.
01 WS-STRING PIC X(15) VALUE 'AABCDACDCCEDDDF'.
PROCEDURE DIVISION.
    INSPECT WS-STRING TALLYING WS-CNT FOR ALL 'D'.
    DISPLAY "WS-CNT:  " WS-CNT.
STOP RUN.

WS-CNT: 05

Table Processing -

How do you handle table processing in COBOL? What are the different table manipulation verbs available?

Table processing is handling mechanism for arrays or tables defined in the Data Division. The table elements are accessed using index variables, and various COBOL statements such as PERFORM, SEARCH, or INSPECT are used for table manipulation and processing.

What is the difference between SEARCH and SEARCH ALL?

SEARCHSEARCH ALL
SEARCH is a linear or sequential search.SEARCH ALL is a binary search.
Should handle index initialization and increment.Only initialization is required for an index. Incrementing is taken care of automatically by the system.
Coding multiple WHEN conditions are allowed and validated.Only one WHEN condition is allowed to code.
Can use arithmetic operators like =, >, <, <=, >=, NOT=.Only = operator is allowed.
Search process is slow.Search process is fast.
SEARCH can be used on single-dimensional and multidimensional tables.SEARCH ALL can be used for only single-dimensional arrays.
Data inside an array need not be in sorted order. Data inside an array should be in a sorted order.

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?

Program is not compiled with SSRANGE option.

Can you define a variable length table? When does space allocation happens for such tables?

Yes. Space allocation will be happend during the runtime.

Why should we cannot define OCCURS clause at 01 level?

The table name is a group variable and should be declared with 01 level. It should not have an OCCURS clause associated with it. So OCCURS cannot come up with 01 level.

What is the difference between subscript and index?

SubscriptIndex
Subscript is no of occurrences of an array. An index is the number of displacement positions of an array.
Subscript should declare separately with S9(04) COMP in WORKING-STORAGE SECTION. The index doesn't require a separate declaration. INDEX BY phrase used to declare it along with table declaration.
Subscript is slow in accessing table data. The index is faster in accessing table data.
Subscript can initialize by using MOVE statement. An index should be initialized by using the SET statement.
Subscript can increase by an ADD statement and decrease by using the SUBTRACT statement. An index can increased and decreased by using the SET statement.

You need to do a SEARCH ALL in a array of 1000 elements sorted in the ascending order, if the first 800 are full, what should you populate in the remaining 200?

High values

What will happen if the array is not in sorted order for SEARCH ALL?

Results are not predictable

Memory Management Techniques -

What is the difference between COMP-1, COMP-2 and COMP-3?

COMP-1COMP-2COMP-3
COMP-1 stores the numbers as single-precision (32 bit) floating-point numbers and applicable to numeric data items. COMP-2 stores the numbers as internal double-precision (64 bit) floating-point numbers and applicable to numeric data items. COMP-3 (or Packed Decimal or Packed Numeric) stores the decimal numbers in a compact binary-coded decimal (BCD) format and applicable to numeric data items.
It has no PICTURE clause. It has no PICTURE clause. It has a PICTURE clause.
1 through 16 digits - 4 bytes (FULL WORD) 1 through 32 digits - 8 bytes (DOUBLE WORD) 1 digit = 1 byte
Data is stored in the format of mantissa and exponent. Data is stored in the format of mantissa and exponent. Data is stored in packed decimal format.

Why is S9(4) COMP needed less space despite knowing that Comp-3 would utilise less space?

S9(04) COMP occupies 4 bytes. S9(4) COMP-3 occupies 3 bytes.

Can I redefine an X(10) field with a field of X(20)?

Yes

Can I redefine an X(200) field with a field of X(100)?

Yes

How many bytes S9(6) USAGE IS COMP will take?

4 bytes (full word)

How many bytes does a S9(7) COMP-3 field occupy?

4 bytes

In which usage, data item is like Long or Double and is represented as double precision floating point number and internally data is stored in hexadecimal format?

COMP-2

File Handling -

What is physical record in COBOL?

One line in the file is one physical record.

What is Logical record in COBOL?

A logical record is the record layout that is used by the COBOL program. Only one record can be processed at a time by the program.

File Declaration -

What is FD and SD in COBOL?

FD is used to specify the file description entry for logical-file-name. SD is used to specify the sort file description entry for logical-file-name.

How can we reference or make COBOL program realise that about the following file formats?

  1. Fixed Block File - Declaration of fixed block file is -
    ORGANIZATION IS SEQUENTIAL
    RECORDING MODE IS F
    BLOCK CONTAINS 0
  2. Fixed Unblock File - Declaration of fixed unblock file is -
    ORGANIZATION IS SEQUENTIAL
    RECORDING MODE IS F
  3. Variable Block File - Declaration of variable block file is -
    ORGANIZATION IS SEQUENTIAL
    RECORDING MODE IS V
    BLOCK CONTAINS 0
  4. Variable Unblock File - Declaration of fixed unblock file is -
    ORGANIZATION IS SEQUENTIAL
    RECORDING MODE IS V
  5. Printer File - Declaration of printer file is -
    ORGANIZATION IS SEQUENTIAL
    RECORDING MODE IS F
    BLOCK CONTAINS 0

File Organization -

What are the different types of file organizations available?

COBOL primarily supports three types of file organizations -

  • Sequential File Organization
  • Indexed File Organization
  • Relative File Organization

What is the difference between a sequential, indexed and relative files in COBOL?

Sequential Files Indexed Files Relative Files
Sequential files are QSAM files. Indexed files are VSAM files. Relative files are VSAM files (RRDS).
Records are written in entry sequential order. Records are written in key sequential order. Records are written in Record Relative Number order.
Duplicate records are allowed to be written into the file. Duplicate records are not allowed to be written into the file. Duplicate records are not allowed to be written into the file.
Records need not be in sorted order. Records are in sorted order based on key. Records are in sorted order based on RRN.
Record deletion is not possible. Records deletion is possible. Records deletion is not possible, but the memory will not reused.
Accessing records is slow because the records can only be read in sequential order. Accessing records is faster because the records can be read dynamically or randomly. Accessing records is faster than indexed files as the records can be read using RRN.
The key concept is not available. The key is available. The key is user-defined and is part of the record. The key is available. The key is system-generated and is outside of a record.
Data can be stored on tape/disk. Data can be stored on disk only. Data can be stored on disk only.
File opening modes are – INPUT, OUTPUT, I-O, and EXTEND. File opening modes are – INPUT, OUTPUT, and I-O. File opening modes are – INPUT, OUTPUT, and I-O.
Sequential files are used frequently. Indexed files are frequently used. Relative files are used very rarely.

File Accessing Modes -

What are the accessing modes in COBOL?

The file access modes specify how data is read from or written to files.

What are different file OPEN modes available in COBOL?

The list of file opening modes are -

  • INPUT
  • OUTPUT
  • I-O
  • EXTEND

Does the record deletion possible in sequential file?

No. Logical deletion is possible which overrides the record data with spaces.

What are the files applicable for dynamic reading?

The applicable files are -

  • Indexed files
  • Relative files

File Processing -

How do we remove the spaces at end of every record in an output file that is of variable length?

Use the reference modification (1:record-length) to get the actual record data to another. Use the same reference modification (record-length+1: max-record-length) to space out the remaining record.

How can we process two files by comparing key fields?

To process two files by comparing key fields in COBOL, you can follow these general steps:

  1. Open the Files: Open both files for input operations.
  2. Read Records: Read the first record from each file.
  3. Compare Key Fields: Compare the key fields from both records to determine if they match, are equal, less than, or greater than each other. This step has more depth and need to code one process for every relation like equal, less than, etc.
  4. Process Matching Records: If the key fields match, perform the required processing on the records from both files.
  5. Advance File Positions: Read the next records from both files.
  6. Repeat Comparison and Processing: Repeat steps 3 to 5 until the end of either file is reached.
  7. Close the Files: Close both files after processing.

Suppose we have two Seq files and we have to check that if there are duplicates in both the files then it should not write anything to the final o/p file. Design approach for this?

Use the same above approach and skip writing the record to the output file when both are matches.

In COBOL Can you point to a key which is greater than or equal to some value and then start reading from that record? If yes how do you do this and what are the file considerations for such a scenario?

Yes this is possible. You can use START Verb to point the record and then you can use READ NEXT clause to start reading the record.

Suppose a program has one i/p file and one o/p file now we want to add another file to the COBOL program and also two new fields (i.e. columns) are added to the o/p file from the new i/p file then how will you do impact analysis?

Check the copybook for the FILLERs if it can be reused. If not then adding the new fields needs to be checked to see what all procs or jobs use it and LRECL needs to be changed. The impacted jobs -
1. where this input file needs to be added. 2. Where this source program is being used what all jobs are using it. 3. Where the copybook is used needs to be recompiled.

If files are not closed in the program, what will happen?

If program execution is successful, file will be closed successfully. If it is unsuccessful, file can't able to used by others.

What will happen if the file is closed before planned?

We can't able to process the file further.

File Status -

How can you handle file processing errors in COBOL, and what are some of the common FILE STATUS codes used for error identification?

When a file operation like OPEN, READ, WRITE, etc., is executed, a status code is returned to the variable coded with the FILE STATUS clause.

What is file status 39 and 92?

39 - File OPEN was unsuccessful because a conflict was detected between the actual file attributes and the attributes specified for that file in the program.
92 - It is a logic error and should correct the program logic.

Internal Sorting -

What is the use of the SORT statement in COBOL, and how can it be used to sort data in memory and on disk?

SORT statement is a powerful statement used for sorting files internally within the program. 3 files are used in the sorting process −

  • Input file
  • Work file
  • Output file

How do I merge two files in COBOL?

MERGE statement is used to combine two or more sequentially ordered files into a single, merged, and sequentially ordered output file. The files should be in sorted order according to the ascending or descending key that is common for both files.

What happens during INPUT PROCEDURE and OUTPUT PROCEDURE?

INPUT PROCEDURE - A procedure is executed for each record of the input file before sorting.

OUTPUT PROCEDURE - A procedure is executed for each record of the sorted file.

Program Communication Statements -

What is the difference between a called and calling program?

Called programCalling program
Main program or calling program calls the sub program to execute a specific task. Sub program or called program that is called by some program to perform a specific task.
CALL statement used in this program Program name used in CALL statement

Difference between GOBACK and STOP RUN?

STOP RUNGOBACK
Control returns to the operating systemControl returns back from where it was received
It should always be coded in the main programIt can code in both the main program and sub-program

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?

No difference and both works as same.

What is the difference between static call and dynamic call?

Static callsDynamic calls
STATIC CALL attaches the SUBPROG load module to the MAINPROG load module to increase processing speed DYNAMIC CALL removes the compilation dependency of MAINPROG when the SUBPROG is modified
Load modules of MAINPROG and SUBPROG are stored togetherLoad modules of MAINPROG and SUBPROG are separately stored
Compiler option should be NODYNAMCompiler option should be DYNAM
Its execution is fasterIts execution is a little slower when compared with STATIC CALL
Can be used on request basis nowadaysIt is the most used one nowadays

What are different ways to pass the parameters from Main program to sub program?

  • BY REFERENCE
  • BY VALUE
  • BY CONTENT

What is the difference between Call By Content and Call By Reference?

Call By ReferenceCall By Content
It passes the address of the parameter memory location to the SUBPROG It is used to pass the copy of the data to the SUBPROG
SUBPROG receives the pointer to the parameter memory location SUBPROG receives a copy of the variable's data at the time of the execution
If the SUBPROG modifies the value of the passing parameter, the new value will be reflected in the MAINPROG If the SUBPROG modifies the value of the passing input variable, the new value will not reflect in the MAINPROG

If the STOP RUN, GOBACK, EXIT PROGRAM is not coded in the sub program, what will happen?

Compilation error occured.

Subroutines -

What is a subroutines? What are the types?

A subroutine is a code block that is not compiled or executed independently. These subroutines can exist within or outside of the application program. There are two types of subroutines -

  • Internal subroutines.
  • External subroutines
    • Subprograms.
    • PROCEDURE DIVISION copybooks.

What is the PROCEDURE DIVISION copybook in COBOL program?

The code block contains the PROCEDURE DIVISION code in it. These are called COBOL includes or PROCEDURE DIVISION copybooks.

What are the types of external subroutines?

These are two types -

  • Subprograms
  • PROCEDURE DIVISION Copybooks

Error Handling -

What is the error handling?

Error handling is a mechanism used to handle the possible runtime errors by notifying the user with a message or routing the program flow to skip the program abend.

What are the different types of error-handling verbs available?

COBOL has specific categories to handle the error conditions -

  • Handling errors in STRING and UNSTRING operations.
  • Handling errors in Arithmetic operations.
  • Handling errors in File operations.
  • Handling errors in CALL statements.

What kind of error is trapped by ON SIZE ERROR option?

The ON SIZE ERROR handles the following cases -

  • Fixed-point overflow.
  • Division by zero.
  • Zero raised to zero power.
  • Zero raised to a negative number.
  • The negative number raised to a fractional power.

What are the causes for S0C1, S0C4, S0C5, S0C7, S0CB abends?

S0C1 - Program tries to execute an instruction which does not exist.

S0C4 - It is a protection exception when tries to reference the memory address which is not part of program runtime memory allocation.

S0C5 - An address developed and used by the program lies outside of the available virtual storage.

S0C7 - It is a data exception. It occurs when tries to move non-numeric data was attempted to move in numeric variable.

S0CB - This operation error may occur when a 'division by zero' occurs.

Consider a scenario where we have a program having an array of 20 items. When the program tries to access the 21st item, the program fails to abend. What is the reason for this?

Abend is S0C4. The reason is, program tries to reference the memory address which is not part of program runtime memory allocation.

Intrinsic Functions -

What is an intrinsic function? What are the categories?

Intrinsic functions are built-in functions that facilitate various operations without the need for extensive procedural logic.

How do you reverse a string in COBOL?

Using REVERSE function

How do you get length of a string in COBOL?

Using LENGTH OF function

Compiler Directive Functions -

How is SSRANGE different from NOSSRANGE?

SSRANGE is used to locate a subscript that is out of range and manage array overflow.
NOSSRANGE ensures no run-time error if a subscript or index is out of range.

What care has to be taken to force program to execute above 16 Meg Line?

Make sure that link option is AMODE=31 and RMODE=ANY. Compile option should never have SIZE (MAX).

Explain the terminologies - AMODE(24), AMODE(31), RMODE(24), and RMODE(ANY)?

  • AMODE(24) - 24 bit addressing. AMODE(31) - 31 bit addressing.
  • AMODE(ANY) - Either 24 bit or 31 bit addressing depending on RMODE.
  • RMODE(24) - Resides in virtual storage below 16 Meg line. Use this for 31 bit programs that call 24 bit programs. (OS/VS Cobol pgms use 24 bit addresses only).
  • RMODE(ANY) - Can reside above or below 16 Meg line.

What is the importance of using REPLACING option in a COPY statement?

It replace the source string with the target string.

What is the use of the EXIT statement in COBOL, and how can it be used to terminate programs and subprograms?

EXIT statement is a "do-nothing" statement mainly used for readability and structure, giving a logical end-point for a section or paragraph.

EXIT PROGRAM marks the end of a subprogram (called program) processing and returns control to the main program (calling program).

Other -

How will you count the number of characters in a null-terminated string?

Use an INSPECT statement to count the number of characters in a null-terminated string:

MOVE 0 TO char-count 
INSPECT source-field TALLYING char-count FOR CHARACTERS BEFORE X"00"

What is included in the change history in the program?

The Change History section displays the activity of changing the requirements, including information about the individual who made the change as well as the date and time of the change. In the event of a change in any field, the change history additionally provides information about the old and new field values.

What are the steps go through while creating a COBOL program executable?

Below are three steps -

  1. Convert source code to an object module.
  2. Link edit COBOL program with any subprogram.
  3. Last but not least create an executable object module.

How do set a return code to the JCL from a COBOL program?

Set system-defined variable RETURN-CODE value in the program. For example -

MOVE 8 TO RETURN-CODE 

What is the aim of using FILLER in programming?

FILLER is used to reserve the buffer memory for future purpose. If new fields needs to be introduced, programmer can reduce the FILLER and introduce new fields.

Does INITIALIZE statement sets default value to the FILLER in programming?

No. It can't.

How to initialize the FILLER in programming?

Initialize the group variable using MOVE statement rather than INITIALIZE.