Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

51.

What Is File Status 39 ?

Answer»

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.

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.

52.

What Is File Status 92?

Answer»

Logic error. e.g., a FILE is OPENED for INPUT and an attempt is made to write to it.

Logic error. e.g., a file is opened for input and an attempt is made to write to it.

53.

Can You Rewrite A Record In An Esds File? Can You Delete A Record From It?

Answer»

Can REWRITE(RECORD LENGTH MUST be same), but not DELETE.

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

54.

In The Jcl, How Do You Define The Files Referred To In A Subroutine ?

Answer»

SUPPLY the DD CARDS just as you would for FILES REFERRED to in the main PROGRAM.

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

55.

What Is The Mode In Which You Will Open A File For Writing?

Answer»

OUTPUT, EXTEND.

OUTPUT, EXTEND.

56.

What Are Different File Open Modes Available In Cobol?

Answer»

OPEN for INPUT, OUTPUT, I-O, EXTEND.

Open for INPUT, OUTPUT, I-O, EXTEND.

57.

What Is The Maximum Size Of A 01 Level Item In Cobol I? In Cobol Ii?

Answer»

In COBOL II: 16777215.

In COBOL II: 16777215.

58.

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.

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.

59.

What Is The Maximum Value That Can Be Stored In S9(8) Comp?

Answer»

99999999.

99999999.

60.

How Many Bytes Will A S9(8) Comp Field Occupy ?

Answer»

4 BYTES.

4 bytes.

61.

How Many Bytes Does A S9(7) Sign Trailing Separate Field Occupy ?

Answer»

Will occupy 8 BYTES (one extra BYTE for sign).

Will occupy 8 bytes (one extra byte for sign).

62.

How Many Bytes Does A S9(7) Comp-3 Field Occupy ?

Answer»

Will take 4 BYTES. Sign is STORED as hex value in the last nibble.
General FORMULA is INT((n/2) + 1)), where n=7 in this example.

Will take 4 bytes. Sign is stored as hex value in the last nibble.
General formula is INT((n/2) + 1)), where n=7 in this example.

63.

How Do You Define A Variable Of Comp-1? Comp-2?

Answer»

No picture CLAUSE to be GIVEN. Example 01 WS-VAR USAGE COMP-1.

No picture clause to be given. Example 01 WS-VAR USAGE COMP-1.

64.

What Is Comp-1? Comp-2?

Answer»

COMP-1 - SINGLE precision floating POINT. USES 4 BYTES.
COMP-2 - Double precision floating point. Uses 8 bytes.

COMP-1 - Single precision floating point. Uses 4 bytes.
COMP-2 - Double precision floating point. Uses 8 bytes.

65.

What Is The Difference Between Comp & Comp-3 ?

Answer»

COMP is a BINARY storage FORMAT while COMP-3 is PACKED decimal format.

COMP is a binary storage format while COMP-3 is packed decimal format.

66.

How Is Sign Stored In A Comp Field ?

Answer»

In the most SIGNIFICANT BIT. Bit is on if -ve, off if +ve.

In the most significant bit. Bit is on if -ve, off if +ve.

67.

How Is Sign Stored In A Comp-3 Field?

Answer»

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

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

68.

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 over PUNCHED with the numeric value stored in the last bite.

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 over punched with the numeric value stored in the last bite.

69.

What Do You Do To Resolve Soc-7 Error?

Answer»

Basically you need to correcting 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 installtion might have BATCH program debugging TOOLS. Use them.

Basically you need to correcting 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 installtion might have batch program debugging tools. Use them.

70.

Can I Redefine An X(200) Field With A Field Of X(100) ?

Answer»

Yes.

Yes.

71.

Can I Redefine An X(100) Field With A Field Of X(200)?

Answer»

Yes. Redefines just causes both fields to start at the same LOCATION. For example:
01 WS-TOP PIC X(1)
01 WS-TOP-RED REDEFINES WS-TOP PIC X(2).
If you MOVE '12' to WS-TOP-RED,
DISPLAY WS-TOP will show 1 while
DISPLAY WS-TOP-RED will show 12.

Yes. Redefines just causes both fields to start at the same location. For example:
01 WS-TOP PIC X(1)
01 WS-TOP-RED REDEFINES WS-TOP PIC X(2).
If you MOVE '12' to WS-TOP-RED,
DISPLAY WS-TOP will show 1 while
DISPLAY WS-TOP-RED will show 12.

72.

What Does Exit Do ?

Answer»

Does NOTHING ! If USED, MUST be the only sentence within a paragraph.

Does nothing ! If used, must be the only sentence within a paragraph.

73.

What Is The Difference Between Continue & Next Sentence ?

Answer»

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

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

74.

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 paraname rather than 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.

75.

How Do You Do In-line Perform?

Answer»

PERFORM ... ...
END PERFORM.

PERFORM ... ...
END PERFORM.

76.

What Is A Scope Terminator? Give Examples?

Answer»

SCOPE TERMINATOR is used to mark the END of a verb e.g. EVALUATE, END-EVALUATE; IF, END-IF.

Scope terminator is used to mark the end of a verb e.g. EVALUATE, END-EVALUATE; IF, END-IF.

77.

In An Evaluate Statement, Can I Give A Complex Condition On A When Clause?

Answer»

Yes.

Yes.

78.

How Do You Come Out Of An Evaluate Statement?

Answer»

After the execution of ONE of the when CLAUSES, the control is AUTOMATICALLY passed on to the next sentence after the EVALUATE statement. There is no NEED of any extra code.

After the execution of one of the when clauses, the control is automatically passed on to the next sentence after the EVALUATE statement. There is no need of any extra code.

79.

What Are The Different Forms Of Evaluate Statement?

Answer»

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
END-EVALUATE END-EVALUATE
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
END-EVALUATE END-EVALUATE.

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
END-EVALUATE END-EVALUATE
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
END-EVALUATE END-EVALUATE.

80.

What Is The Use Of Evaluate Statement?

Answer»

EVALUATE is like a case statement and can be used to replace nested Ifs. The difference between EVALUATE and case is that no 'break' is required for EVALUATE i.e. control COMES out of the EVALUATE as soon as ONE match is MADE.

Evaluate is like a case statement and can be used to replace nested Ifs. The difference between EVALUATE and case is that no 'break' is required for EVALUATE i.e. control comes out of the EVALUATE as soon as one match is made.

81.

What Is The Difference Between Performing A Section And A Paragraph?

Answer»

PERFORMING a SECTION will cause all the PARAGRAPHS that are part of the section, to be PERFORMED.
Performing a PARAGRAPH will cause only that paragraph to be performed.

Performing a SECTION will cause all the paragraphs that are part of the section, to be performed.
Performing a PARAGRAPH will cause only that paragraph to be performed.

82.

How Do You Define A Sort File In Jcl That Runs The Cobol Program?

Answer»

Use the SORTWK01, SORTWK02,..... dd names in the STEP. Number of sort datasets DEPENDS on the volume of data being SORTED, but a minimum of 3 is REQUIRED.

Use the SORTWK01, SORTWK02,..... dd names in the step. Number of sort datasets depends on the volume of data being sorted, but a minimum of 3 is required.

83.

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.

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

84.

What Is Binary Search?

Answer»

Search on a sorted ARRAY. Compare the item to be searched with the item at the CENTER. If it matches, fine else REPEAT the process with the LEFT HALF or the right half depending on where the item lies.

Search on a sorted array. Compare the item to be searched with the item at the center. If it matches, fine else repeat the process with the left half or the right half depending on where the item lies.

85.

What Should Be The Sorting Order For Search All?

Answer»

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

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

86.

What Is The Difference Between Search And Search All?

Answer»

SEARCH - is a SERIAL search.
SEARCH ALL - is a binary search & the table MUST be SORTED
ASCENDING/DESCENDING KEY clause to be used & data loaded in this order) before using SEARCH ALL.

SEARCH - is a serial search.
SEARCH ALL - is a binary search & the table must be sorted
ASCENDING/DESCENDING KEY clause to be used & data loaded in this order) before using SEARCH ALL.

87.

What Is The Difference Between Index And Subscript?

Answer»

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.

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.

88.

Can The Occurs Clause Be At The 01 Level?

Answer»

No.

No.

89.

How Do You Define A Table/array In Cobol?

Answer»

01 ARRAYS.
05 ARRAY1 PIC X(9) OCCURS 10 TIMES.
05 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX.

01 ARRAYS.
05 ARRAY1 PIC X(9) OCCURS 10 TIMES.
05 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX.

90.

What Does The Is Numeric Clause Establish ?

Answer»

IS NUMERIC can be USED on ALPHANUMERIC items, SIGNED numeric & packed decimal items and usigned numeric & packed decimal items. IS NUMERIC returns TRUE if the item only consists of 0-9. However, if the item being TESTED is a signed item, then it may contain 0-9, + and - .

IS NUMERIC can be used on alphanumeric items, signed numeric & packed decimal items and usigned numeric & packed decimal items. IS NUMERIC returns TRUE if the item only consists of 0-9. However, if the item being tested is a signed item, then it may contain 0-9, + and - .

91.

What Is Level 66 Used For ?

Answer»

For RENAMES CLAUSE.

For RENAMES clause.

92.

What Is 88 Level Used For ?

Answer»

For CONDITION NAMES.

For condition names.

93.

What Is 77 Level Used For ?

Answer»

ELEMENTARY LEVEL item. Cannot be SUBDIVISIONS of other items (cannot be QUALIFIED), nor can they be subdivided themselves.

Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themselves.

94.

What Does The Initialize Verb Do?

Answer»

Alphabetic, ALPHANUMERIC fields & alphanumeric edited items are set to SPACES.
Numeric, Numeric edited items set to ZERO.
FILLER , OCCURS DEPENDING ON items left UNTOUCHED.

Alphabetic, Alphanumeric fields & alphanumeric edited items are set to SPACES.
Numeric, Numeric edited items set to ZERO.
FILLER , OCCURS DEPENDING ON items left untouched.

95.

What Are The Different Data Types Available In Cobol?

Answer»

Alpha-NUMERIC (X), ALPHABETIC (A) and numeric (9).

Alpha-numeric (X), alphabetic (A) and numeric (9).

96.

Name The Divisions In A Cobol Program?

Answer»

IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, DATA DIVISION, PROCEDURE DIVISION.

IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, DATA DIVISION, PROCEDURE DIVISION.