0% found this document useful (0 votes)
2K views62 pages

Cobol Quiz

The document contains 19 multiple choice questions about COBOL programming concepts. Key points covered include: - How sign is stored in COMP-3 fields (last nibble) - The length of a PIC 9.999 field (5 bytes) - That SEARCH ALL performs a binary search - Moving a numeric field to alphanumeric is legal in COBOL - The output of a sample DIVIDE statement program (06, 10) The majority of the questions ask about basic COBOL syntax, data types, and language elements like divisions, sections, and statements. The last question indicates that ACCEPT cannot be used as a user-defined word since it is a COBOL reserved word

Uploaded by

Shankar Rauniyar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views62 pages

Cobol Quiz

The document contains 19 multiple choice questions about COBOL programming concepts. Key points covered include: - How sign is stored in COMP-3 fields (last nibble) - The length of a PIC 9.999 field (5 bytes) - That SEARCH ALL performs a binary search - Moving a numeric field to alphanumeric is legal in COBOL - The output of a sample DIVIDE statement program (06, 10) The majority of the questions ask about basic COBOL syntax, data types, and language elements like divisions, sections, and statements. The last question indicates that ACCEPT cannot be used as a user-defined word since it is a COBOL reserved word

Uploaded by

Shankar Rauniyar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 62

===================================================================================

======================================
COBOL
===================================================================================
======================================

Q 1 - How is sign stored in a COMP-3 field?

A - First Bit

B - Last Bit

C - First Nibble

D - Last Nibble

Answer : D
Explanation
In COMP-3 field, sign is stored in last nibble.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
---------------------------------------------------------
Q 2 - What is the length of PIC 9.999?

A - 4

B - 6

C - 5

D - 3
-----------------------------------------------------------------------------------
-------------------------
Q 3 - What does SEARCH ALL do?

A - Linear search

B - Binary search

C - Sequential search

D - None of these

Answer : B
Explanation
Search All is a binary search method, which is used to find elements inside the
table.
-----------------------------------------------------------------------------------
--------------------------------
Q 4 - Moving a Numeric field to Alphanumeric is legal?

A - Yes

B - No

Answer : A
Explanation
Moving a numeric field to alphanumeric is legal in COBOL.
-----------------------------------------------------------------------------------
-----------------------------------
Q 5 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUMA PIC 9(9) VALUE 100.
01 WS-NUMB PIC 9(9) VALUE 15.
01 WS-NUMC PIC 9(2).
01 WS-REM PIC 9(2).

PROCEDURE DIVISION.
DIVIDE WS-NUMA BY WS-NUMB GIVING WS-NUMC REMAINDER WS-REM.
DISPLAY WS-NUMC ', ' WS-REM

STOP RUN.
A - 06, 10

B - 10, 06

C - Error

D - 100, 15

Answer : A
Explanation
Formula will be like WS-NUMC = NUMA/NUMB and remainder will be stored in WS-REM.

You can try same code using Try it option available below:

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUMA PIC 9(9) VALUE 100.
01 WS-NUMB PIC 9(9) VALUE 15.
01 WS-NUMC PIC 9(2).
01 WS-REM PIC 9(2).

PROCEDURE DIVISION.
DIVIDE WS-NUMA BY WS-NUMB GIVING WS-NUMC REMAINDER WS-REM.
DISPLAY WS-NUMC ', ' WS-REM
STOP RUN.
-----------------------------------------------------------------------------------
----------------------------------
Q 6 - With test before is the default condition and it indicates that the condition
is checked before the execution of statements in a paragraph. Is this statement
true or false?

A - False

B - True

Answer : B
Explanation
This statement is true as with test before is the default condition for Perform
until statement.
-----------------------------------------------------------------------------------
-----------------------------------------
Q 7 - For deleting a record, in which mode we should open the file?

A - Input-Output

B - Input

C - Output

D - Extend

Answer : A
Explanation
Delete verb can be performed only on indexed and relative files. The file must be
opened in I-O mode. In sequential file organization, records cannot be deleted. The
record last read by the Read statement is deleted in case of sequential access
mode. In random access mode, specify the record key and then perform the Delete
operation.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
---------------------------------------------------------
Q 8 - In which usage, data item is similar to Long or Double and is represented as
double precision floating point number and internally data is stored in hexadecimal
format?

A - COMP

B - COMP-3

C - COMP-2

D - COMP-1

Answer : C
Explanation
COMP-2 is represented as double precision floating point number and internally data
is stored in hexadecimal format.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------------
Q 9 - Which division provides information of external data sets used in the
program?

A - PROCEDURE DIVISION.

B - IDENTIFICATION DIVISION

C - DATA DIVISION

D - ENVIRONMENT DIVISION

Answer : D
Explanation
In file control paragraph inside Environment division we mention all the
information of external data sets used in the program.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
---------------------------------------------------------
Q 10 - 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?

A - True

B - False

Answer : A
Explanation
This statement is correct.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--------------------------------------------------------
Q11 Q - Moving a Alphabetic field to Numeric is legal?

A - Yes

B - No

Answer : B
Explanation
Moving a alphabetic field to numeric field is illegal in COBOL. It will throw
error.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
---------------------
Q12 - In which division, Linkage Section comes?

A - Identification Division

B - Environment Division

C - Data Division

D - Procedure Division

Answer : C
Explanation
Linkage section comes under data division which is used in called program.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------------------
Q13 - What is the position of Area A in COBOL program?

A - 1-6 Columns

B - 8-11 Columns

C - 12-72 Columns

D - 72-80 Columns

Answer : B
Explanation
Area A starts from 8 to 11 column. All COBOL divisions, sections, paragraphs and
some special entries must begin in Area A.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------
Q14 - Which is the mandatory division in COBOL program?

A - PROCEDURE DIVISION.

B - IDENTIFICATION DIVISION

C - DATA DIVISION

D - ENVIRONMENT DIVISION

Answer : B
Explanation
Identification division contains entries that is used to identify the program. This
is the the first division and only mandatory division.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------
Q15 - How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy?

A - 7 bytes

B - 8 bytes

C - 4 bytes

D - 10 bytes

Answer : B
Explanation
9(7) will take 7 bytes and 1 byte for SIGN TRAILING SEPARATE, so total 8 bytes it
will take.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
---------------------------------------------------------Q16 - What will happen if
you code GO BACK instead of STOP RUN in a stand alone COBOL program?

A - Program will give run time error.

B - Program will go in infinite loop.

C - Program will execute normally.

D - Program will throw compilation error.

Answer : B
Explanation
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.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
------------------------------------------------------
Q17 - If the values of variables in the called program are modified, then their new
values will reflect in the calling program. What type of call is this?

A - Call by content
B - Call by reference

C - None of these

Answer : B
Explanation
The new values will reflect in the calling program when we use call by reference.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------------------
Q18 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUM1 PIC X(4) VALUE '15AB'.

PROCEDURE DIVISION.
MOVE 'XXXX' TO WS-NUM1
DISPLAY WS-NUM1.
STOP RUN.
A - 15AB

B - XXXX

C - Compilation error

D - Run time error

Answer : B
Explanation
Value of WS-NUM1 will be displayed. While declaring the WS-NUM1 variable we have
set the value as '15AB' but in the procedure division we have moved 'XXXX' value in
WS-NUM1. So XXXX value is displayed.

You can try same code using Try it option available below:

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUM1 PIC X(4) VALUE '15AB'.

PROCEDURE DIVISION.
MOVE 'XXXX' TO WS-NUM1
DISPLAY WS-NUM1.
STOP RUN.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--------------------------------------------------
Q19 - Which of the following word cannot be a user-defined COBOL word?

A - WS-ACCEPT

B - ACCEPT
C - WS-DISPLAY

D - TUTORIAL

Answer : B
Explanation
ACCEPT cannot be a user defined COBOL word as we cannot use COBOL reserved words.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
------------------------------------------------------
Q20 - How records are stored & accessed in indexed file organization?

A - Relative address method

B - Sequential access method

C - Direct access method

D - Both B & C

Answer : D
Explanation
An indexed sequential file consists of records that can be accessed sequentially.
Direct access is also possible.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--------------------------------------------------------
Q21 - What is the maximum size of a numeric field we can define in COBOL?

A - 9(20)

B - 9(18)

C - 9(31)

D - 9(10)

Answer : B
Explanation
COBOL applications use 31 digit numeric fields. However, compiler only supports a
maximum of 18 digits. So we use a maximum of 18 digits.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--------------------------------------------------------
Q22 - What is the output of the following code?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUM1 PIC 9(9).
01 WS-NUM2 PIC 9(6).

PROCEDURE DIVISION.
A000-FIRST-PARA.
MOVE 123456789 TO WS-NUM1.
MOVE WS-NUM1(3:6) TO WS-NUM2.
DISPLAY WS-NUM2

STOP RUN.
A - 456789

B - 000000

C - 123456

D - 345678

Answer : D
Explanation
WS-NUM1(3:6) indicates that select from 3rd column & up to 6 digits. So result will
345678.

You can try same code using Try it option available below:

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUM1 PIC 9(9).
01 WS-NUM2 PIC 9(6).

PROCEDURE DIVISION.
A000-FIRST-PARA.
MOVE 123456789 TO WS-NUM1.
MOVE WS-NUM1(3:6) TO WS-NUM2.

DISPLAY WS-NUM2
STOP RUN.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------
Q23 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

PROCEDURE DIVISION.
A-PARA.
PERFORM DISPLAY 'A'
END-PERFORM.
PERFORM C-PARA THRU E-PARA.

B-PARA.
DISPLAY 'B'.
STOP RUN.

C-PARA.
DISPLAY 'C'.

D-PARA.
DISPLAY 'D'.

E-PARA.
DISPLAY 'E'.
A - ACDEB

B - ADCEB

C - DEBAC

D - DACEB

Answer : A
Explanation
This is to show how control goes from one Perform statement to other. Go step by
step you will understand the flow.

You can try same code using Try it option available below:

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

PROCEDURE DIVISION.
A-PARA.
PERFORM DISPLAY 'A'
END-PERFORM.
PERFORM C-PARA THRU E-PARA.

B-PARA.
DISPLAY 'B'.
STOP RUN.

C-PARA.
DISPLAY 'C'.

D-PARA.
DISPLAY 'D'.

E-PARA.
DISPLAY 'E'.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--------------------------------------------------------
Q24 - Which of the numeric literal is invalid?

A - 100

B - 10.9-

C - -10.9

D - 10.9

Answer : B
Explanation
10.9- is invalid because sign can not be mentioned on the right.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
------------------------------------------------------
Q25 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUM1 PIC 9(9).
01 WS-NUM2 PIC 9(9).

PROCEDURE DIVISION.
A000-FIRST-PARA.
MOVE 25 TO WS-NUM1
MOVE 15 TO WS-NUM2

IF WS-NUM1 > WS-NUM2 THEN


DISPLAY 'IN LOOP 1 - IF BLOCK'
ELSE
DISPLAY 'IN LOOP 1 - ELSE BLOCK'
END-IF.

STOP RUN.
A - IN LOOP 1 - ELSE BLOCK

B - IN LOOP 1 - IF BLOCK

C - Error

D - None of these

Answer : B
Explanation
WS-NUM1 is greater than WS-NUM2, so condition is satisfied and it will to IF loop.

You can try same code using Try it option available below:

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUM1 PIC 9(9).
01 WS-NUM2 PIC 9(9).

PROCEDURE DIVISION.
A000-FIRST-PARA.
MOVE 25 TO WS-NUM1
MOVE 15 TO WS-NUM2

IF WS-NUM1 > WS-NUM2 THEN


DISPLAY 'IN LOOP 1 - IF BLOCK'
ELSE
DISPLAY 'IN LOOP 1 - ELSE BLOCK'
END-IF.

STOP RUN.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--------------------------------------------------------
Q26 - What is the mode in which you will OPEN a file for writing?

A - OUTPUT
B - EXTEND

C - Either OUTPUT or EXTEND

D - INPUT-OUTPUT

Answer : C
Explanation
To write into a file, the file has to be opened in either OUTPUT or EXTEND mode.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------------
Q27 - Moving a Numeric field to Alphabetic is legal?

A - Yes

B - No

Answer : B
Explanation
Moving a numeric field to alphabetic field is illegal in COBOL. It will throw
error.

Q28 - Where does Column numbers in COBOL start from?

A - 01 to 07 columns

B - 12 to 72 columns

C - 08 to 11 columns

D - 73 to 80 columns

Answer : A
Explanation
01-07 are reserved for line numbers.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------------
Q28 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUMA PIC 9(9) VALUE 10.
01 WS-NUMB PIC 9(9) VALUE 10.
01 WS-NUMC PIC 9(9) VALUE 10.
01 WS-NUMD PIC 9(9) VALUE 100.
01 WS-NUME PIC 9(9) VALUE 10.

PROCEDURE DIVISION.
SUBTRACT WS-NUMA WS-NUMB WS-NUMC FROM WS-NUMD GIVING WS-NUME.
DISPLAY WS-NUME.

STOP RUN.
A - 000000100
B - 000000090

C - 000000070

D - 000000080

Answer : C
Explanation
The formula will be like (WS-NUME = WS-NUMD - WS-NUMA - WS-NUMB - WS-NUMC).

You can try same code using Try it option available below:

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUMA PIC 9(9) VALUE 10.
01 WS-NUMB PIC 9(9) VALUE 10.
01 WS-NUMC PIC 9(9) VALUE 10.
01 WS-NUMD PIC 9(9) VALUE 100.
01 WS-NUME PIC 9(9) VALUE 10.

PROCEDURE DIVISION.
SUBTRACT WS-NUMA WS-NUMB WS-NUMC FROM WS-NUMD GIVING WS-NUME.
DISPLAY WS-NUME.

STOP RUN.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------------
29. Rewrite verb is used to update the records. A file should be opened in I-O mode
for rewrite operations.
It can be used even if a read operation is not successful. Is this statement
true or false?
A. True.
B. False
C. All the above
D. None

Option B

30. Indicate in which of the following, the REPORT NAME does not appear
A. RD entry
B. INITIATE statement
C. SELECT clause
D. TERMINATE statement

Option C

32 About the MERGE verb, which one of the following is true.


A. Can merge a maximum of three files
B. Does not require that the input file to be merged be sorted on the merge keys
C. Requires that all files mentioned in the statement must have records of same
size
D. Does not require that the position of the merge keys with in the records
descriptions of each of the files must be same
Option C

33. Indicate which of the following is not a Procedure Division verb


A. Rewrite
B. Insert
C. Delete
D. Start

Option D

34. What is the mode in which you will OPEN a file for writing?
A. Output
B. Input
C. Extend
D. Both A & C

Option D

35. A storage device which is used to store data & information external to the main
storage is known as?
A. Buffer.
B. Backing storage
C. PROM
D. Accumulator

OPtion B

36. Pic 9v99 is a _______ position numeric field with an implied or assumed decimal
point after the first position.
A. One
B. Two
C. Three
D. Four

OPtion C

37. What is the edited value of the picture clause PIC field 9999+ Numeric value
moved to the field -382 and the Edited value is
A. 0382
B. 3820
C. 0038
D. 0003

Option A

38. Which of the following storage and retrieval methods would be well suited to
your processing requirements'
if you only need to retrieve records one at a time and there is no fixed pattern
to the requests
for data and records?
A. indexed sectors
B. sequential
C. direct
D. indexed direct

Option D

39. Which division is used to specify the computer used by the program
A. Identification Division
B. Environment Division
C. Data Division
D. Procedure Division

Option B

40. In which section do sort description is given?


A. Working-Storage
B. File Section
C. Linkage Section
D. Control Section

Option B

41. What does COBOL stands for?


A. Common Business Oriented Language
B. Common Business Object Language
C. Common Oriented Business Language
D. Common Object Business Language

Option A

42. Select variable which is accessible only to the batch program.


A. Local
B. Global
C. External
D. Internal

OPtion B

43. Which of the following is not a figurative constant?


A. SPACES
B. QUOTE
C. BLANK
D. LOW-VALUE

Option C

44. Indicate which of the following is not a PROCEDURE DIVISION verb


A. REWRITE
B. INSERT
C. DELETE
D. START

Option B

45. About the MERGE verb, which one of the following is true.
A. Can merge a maximum of three files.
B. Does not require that the input file to be merged be sorted on the merge keys.
C. Requires that all files mentioned in the statement must have records of same
size.
D. Does not require that the position of the merge keys with in the records
descriptions of each of the files must be same.

OPtion C

46. Which division is used to specify the computer used by the program
A. Identification Division
B. Environment Division
C. Data Division
D. Procedure Divisionwrong

Option B

47. What is the edited value of the picture clause PIC field 9999+ Numeric value
moved to the field -382
and the Edited value is
A. 0382-
B. 3820-
C. -0038
D. -0003

OPtion A

48. A storage device which is used to store data & information external to the main
storage is known as?
A. Buffer
B. Backing storage
C. PROM
D. Accumulator

OPtion B

49. To develop commercial applications that require precise and efficient


manipulation of data, we use
A. FORTRAN
B. COBOL
C. Pascal
D. Ada

Option B

50. How many bytes will a S9(8) COMP field occupy?


A. 8 bytes
B. 4 bytes
C. 2 bytes
D. 5 bytes

Option B

51. The Max length of Parm Parameter is


A. 100
B. 200
C. 75
D. None of the Above

Option A

52. The following statement WRITE OUT-REC. Which one of the following modes of
operating the Sequential file is not true
A. OPEN INPUT
B. OPEN OUTPUT
C. OPEN EXTEND
D. OPEN INPUT-OUTPUT

Option A
53. Select statement which is used to block the COBOL statements between them.
A. PERFORM and END-PERFORM statements
B. IN-LINE PERFORM Statement
C. OUT-LINE PERFORM Statement
D. PERFORM and PERFORM-END statements

Option A

54. Which of the following storage and retrieval methods would be well suited to
your processing requirements if you only need to retrieve records one at a time
and there is no fixed pattern to the requests for data and records?
A. indexed sectors
B. sequential
C. direct
D. indexed directcorrect

Option D

55. COBOL 'Common Business Oriented Language' was developed in


A. 1940s
B. 1950s
C. 1960s
D. 1970s

Option B

57. Consider the following program.


PERFORM 10 TIMES
IF A=B
NEXT SENTENCE
ELSE
DISPLAY B
END-IF
END-PERFORM.
If after 5th iteration A becomes equal to B then what happens.
A. Program will go into a loop.
B. It will do the 6th iteration.
C. It will come out of the perform loop.correct
D. It will come out of the if loop and do the 6th iteration.

Option C

58. Indicate which of the following statement is not allowed when a relative file
is opened in I-O mode and access is RANDOM.
A. READ
B. WRITE
C. REWRITE
D. START

Option C

59. Indicate in which of the following, the REPORT NAME does not appear
A. RD entry
B. INITIATE statement
C. SELECT clause
D. TERMINATE statement

Option C
60. What is file status 92?
A. It is a logical error
B. It is a logical error, file is opened for input and attempt is made to write
itwrong
C. It is not an logical error
D. It is a logical error, It is not file related error

Option C

61. How records are stored & accessed in relative file organization?
A. Relative address
B. Sequentially
C. Directly
D. Both B & C

Option A

62. The ___ cobol verb is used while updating a file.


A. Write.
B. Update.
C. Read
D. Rewrite

OPtion D

63. Select single precision floating point in the COBOL.


A. COMP-4
B. COMP-2
C. COMP-1
D. COMP-3

Option C

64. In ___ organization the records are stored in contiguous allocation.


A. Sequential
B. Indexed
C. Relative
D. None

Option A

65. To update an indexed record we use a __________ statement.


A. Update
B. Write
C. Rewrite
D. Read

Option C
===================================================================================
===================================================================================
============================================================================

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


a. Yes
b. No
c. Can’t say

2) How is sign stored in a COMP field?


a. In the least significant bit
b. In the last nibble
c. Over punched with the numeric value
d. In the most significant bit

3) How many bytes will a S9(8) COMP field occupy?


a. 8 bytes
b. 4 bytes
c. 2 bytes
d. 5 bytes

4) What is SET TO TRUE all about?


a. Set value to condition name variable
b. Set value to related data item
c. Set value to index
d. None

5) What is the length of PIC 9. 99?


a. 3
b. 4
c. 5
d. 2

6) 01 TEST RECORD
02 FIRST PIC X(4)
02 SECOND REDEFINES FIRST PIC S9(4) COMP
will give
a. S0C7
b. Logic error
c. Compile error
d. No error

7) The PIC clause of file status should be


a. XX.
b. 99
c. AA
d. a or b

8) What is the mode in which you will OPEN a file for writing?
a. OUTPUT
b. INPUT
c. EXTEND
d. a & c

9) In a COBOL PERFORM statement, when is the condition tested?


a. After the perform
b. Before the perform
c. Can’t say
d. System dependent

10) COPY statement requires _____ compiler option to be in effect


a. RENT
b. LIB
c. DYNAM
d. NODYNAM

11) The Max length of Parm Parameter is


a. 100
b. 200
c. 75
d. None of the Above

12) The Logical Name of the File will be assigned to


a. DD Name
b. Step Name
c. Job Name
d. Joblib

13) What is mean by Half Word Binary


a. S9(8) comp
b. S9(4) comp
c. 9(4) comp
d. S9(2) comp

14) When displaying a data-name, it _______ be part of an output record.


a. Must
b. Mustn’t
c. Need not
d. Can’t say

15) The ___ cobol verb is used while updating a file.


a. Write.
b. Update.
c. Read
d. Rewrite

16) The____ statement release the resources which are assigned to that file
a. STOP RUN
b. EXIT.
c. WRITE
d. END

17) In a sort file, names used must be in the ........entry.


a. FD
b. SD
c. MD
d. None

18) In an EVALUATE statement, can we give a complex condition on a when clause?


a. Yes
b. No

19) Can a copy member with nested COPY statements


contain the Replacing option?
a. Yes
b. No

20) Consider the following program.


PERFORM 10 TIMES
IF A=B
NEXT SENTENCE
ELSE
DISPLAY B
END-IF
END-PERFORM.
If after 5th iteration A becomes equal to B then what happens.
a. Program will go into a loop.
b. It will do the 6th iteration.
c. It will come out of the perform loop.
d. It will come out of the if loop and do the 6th iteration.

ANS-

1) a
2) d
3) b
4) –
5) b
6) d
7) a
8) d
9) –
10) –
11) a
12) a
13) b
14) c
15) d
16) a
17) b
18) a
19) b
20) c

1) If PIC clause for a data item is PPPP999 and the value moved to the data-item is
234 then the edited value taken is
a. 234
b. 2340000
c. .0000234
d. None of the above

2) To update an indexed record we use a __________ statement.


a. Update
b. Write
c. Rewrite
d. Read

3) When displaying a data-name, it _______ be part of an output record.


a. Must
b. Mustn’t
c. Need not
d. Can’t say

4) The device specified in the Environment Division will change significantly, if


the program is run on the different computer.
a. True
b. False

5) 01 TRANSACTION-REC.
05 DATE-OF-SALE PIC 9999.
10 MONTH PIC 99.
10 YEAR PIC 99.
a. It’s a valid statement(entry)
b. It’s an invalid statement(entry)

6) Identify the correct statement;


a. Unlike a Write statement in which the file-name is specified, a Read statement
specifies the record-name.
b. Unlike a Read statement in which the file-name is specified, a Write statement
specifies the record-name.
c. Both are incorrect.

7) In file handling, the file status of 34 indicates


a. Permanent error
b. Permanent error due to boundary violation
c. Invalid key due to boundary violation
d. Invalid key due to no record found

8) How is sign stored in packed decimal representation of fields


a. Sign is stored as a binary value in the last nibble of storage
b. Sign is stored as a hex value in the last nibble of storage
c. As a default, sign is over punched with the numeric value stored in the last
byte
d. None of the above

9) If you were passing a table via linkage


a. A subscript is preferable
b. Index is preferable
c. Both can be used
d. Can’t say

10) Indicate which of the following statement is not allowed when a relative file
is opened in I-O mode and access is RANDOM.
a. READ
b. WRITE.
c. REWRITE
d. START.

11) The ___ cobol verb is used while updating a file.


a. Write.
b. Update.
c. Read
d. Rewrite

12) The____ statement release the resources which are assigned to that file
a. STOP RUN
b. EXIT.
c. WRITE
d. END

13) The sort file name in the SORT syntax used must be in a ........entry.
a. FD
b. SD
c. MD
d. None

14) In an EVALUATE statement, can we give a complex condition on a when clause?


a. Yes
b. No

15) What is the Next Sentence statement.


a. Gives control to the next verb after the explicit scope terminator
b. Gives control to the next line
c. Gives control to the verb following the last period.
d. A AND B..
16) Can a copy member with nested COPY statements
contain the Replacing option?
a. Yes
b. No

17) Called program can contain Call statements.


a. True
b. False

18) In ......organization the records are stored in contiguous allocation.


a. Sequential
b. Indexed
c. Relative
d. None

19) If you want to store two variables say, subscript and amount in a COMP and
COMP-3 field, which one is preferred.
b. For a subscript COMP is preferred and for the amount COMP-3 is preferred.
c. For a subscript COMP-3 is preferred and for the amount COMP is preferred.
d. For a both subscript and amount COMP is preferred.
e. For a both subscript and amount COMP-3 is preferred.

20) Consider the following program.


PERFORM 10 TIMES
IF A=B
NEXT SENTENCE
ELSE
DISPLAY B
END-IF
END-PERFORM.
If after 5th iteration A becomes equal to B then what happens.
a. Program will go into a loop.
b. It will do the 6th iteration.
c. It will come out of the perform loop.
d. It will come out of the if loop and do the 6th iteration.

ANS-COBOL
1 –c
2 –c
3 –c
4 –a
5 –b
6 –b
7 –b
8 –b
9 –a
10-c
11-d
12-a
13-b
14-a
15-c
16-b
17-a
18-a
19-b
20-c
1) JUSTIFIED RIGHT
a. Eliminates the need for extra filler area
b. Move in the procedure division is required to achieve right-justification of
data
c. Both (a) and (b)
d. None of the above

2) OCCURS clause can be specified for


a. An elementary item
b. Group item
c. Both (a) and (b)
d. None of the above

3) ___________ verb is used to alter the value of index in COBOL


a. Alter
b. Move
c. Set
d. Both (b) and (c)

4) To update an indexed record we use a __________ statement.


a. Update
b. Write
c. Rewrite
d. Read

5) When displaying a data-name, it _______ be part of an output record.


a. Must
b. Mustn’t
c. Need not
d. Can’t say

6) In the statement; CALL literal-1 USING identifier-1 ….


The identifier specified in the USING clause is defined in
a. Working-storage section
b. Linkage-section
c. File-section
d. Local-storage section

7) The device specified in the Environment Division will change significantly,


if the program is run on the different computer.
a. True
b. False

8) ADD CORRESPONDING identifier-1 TO identifier-2.


a. Identifier-1 and identifier-2 must not be data items with level numbers 66, 77,
and 88
b. Identifier-1 and identifier-2 can have a REDEFINES clause
c. Identifier-1 and identifier-2 can have a OCCURS clause
d. All the above

9) PERFORM RANGE-TO-BE-EXECUTED
VARYING I FROM 1 BY 1 UNTIL I>15
AFTER J FROM 1 BY 1 UNTIL J>10
a. The range RANGE-TO-BE-EXECUTED will be performed 150 times
b. The range RANGE-TO-BE-EXECUTED will be performed 15 times
c. The range RANGE-TO-BE-EXECUTED will be performed 1 times
d. Won’t be performed, there will be a error message

10) The ____________ statement can only be used if the file is opened in I-O mode
a. Write
b. Read
c. Rewrite
d. All the above

11) A COPY statement cannot occur within another COPY statement


a. True
b. False

12) In file handling, the file status of 34 indicates


a. Permanent error
b. Permanent error due to boundary violation
c. Invalid key due to boundary violation
d. Invalid key due to no record found

13) The utility for compiling COBOL program is


a. IEWL
b. IGYCRCTL
c. IGYCTCRL
d. IKJEFT01

14) How is sign stored in packed decimal representation of fields


a. Sign is stored as a binary value in the last nibble of storage
b. Sign is stored as a hex value in the last nibble of storage
c. As a default, sign is over punched with the numeric value stored in the last
byte
d. None of the above

15) While defining a variable with COMP-1


a. Picture clause may be given
b. Picture clause need not be given
c. Picture clause cannot be given
d. Picture clause must be given

16) How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy
a. 4 bytes
b. 6 bytes
c. 8 bytes
d. 10 bytes

17) Mismatch in LRECL or BLKSIZE or RECFM between COBOL program and the JCL gives
you a file status of
a. 35
b. 37
c. 39
d. 41

18) If you were passing a table via linkage


a. A subscript is preferable
b. Index is preferable
c. Both can be used
d. Can’t say
19) Consider the following code:
01 WS-N PIC 9(2) VALUE ZERO.
A-PARA.
MOVE 5 TO WS-N.
PERFORM B-PARA WS-N TIMES.
B-PARA.
MOVE 10 TO WS-N.
How many times will B-PARA be executed
a. 5 times
b. 50 times
c. 15 times
d. Zero times

20) The PIC clause of file status should be


a. XX
b. 99
c. AA
d. a or b

ANS-

1) –
2) c
3) c
4) c
5) c
6) b
7) a
8) d
9) a
10) d
11) b
12) b
13) b
14) b
15) c
16) c
17) c
18) b
19) a
20) –

-----------------------------------------------------------------------------------
------------------------------

1. Data name in COBOL may have a maximum of


a) 18 characters
b) 30 characters
c) 24 characters
d) 8 characters

2. The difference between ‘*’ and ‘/’ is that in case of ‘/’ the comment line will
be printed after page ejection.
a) True
b) False

3. The maximum length of numeric literals can be


a) 120 digits
b) 18 digits
c) 44 digits
d) None of the above

4. The maximum length of non-numeric literals can be


a) 18 characters
b) 124 characters
c) 254 characters
d) 120 characters

5. While defining a numerical data item, the occurrence of ‘P’ indicates the
position of the assumed decimal point when the point lies ______________ the data
item.
a) Inside
b) Outside
b) Within
d) None of the above

6. Paragraph names need not be unique in the entire program


a) True
b) False
c) Can’t say

7. A level 66 entry cannot rename another


a) Level 01 and level 77 entry
b) Level 66 and level 88 entry
c) Level 01 and level 88 entry
d) Level 01, 66, 77, 88 entry

8. The USAGE clause cannot be specified for


a) Level 01 and level 77 entry
b) Level 66 and level 88 entry
c) Both (a) and (b)
d) There is no such restriction

9. Which of the following is a packed decimal data representation


a) COMP
b) COMP-1
c) COMP-2
d) COMP-3

10. An index data item cannot be specified in a MOVE statement


a) True
b) False

11. In reference modification, the data name must have USAGE


a) DISPLAY
b) COMP
c) COMP-3
d) Can’t say

12. SUBTRACT C from 100 is


a) Valid
b) Invalid
c) Can’t say

13. In the statement, SORT file-name1 ON ASCENDING KEY data-name1 USING file-name2
GIVING file-name3
a) file-name2 and file-name3 can be same
b) file-name2 and file-name3 must be different
c) Can’t say

14. The CALL… BY CONTENT technique


a) Can change the original data values in caller’s storage
b) Cannot change the original data values in the caller’s storage
c) Allows the sub-program to access and process a copy of the data-items from the
caller’s storage
d) Both (a) and (c)

15. If a data item is given packed decimal representation and value to be stored is
+3456789 then the PIC clause will be
a) S9(8)
b) S9(4)COMP-3
c) S9(4)COMP
d) S9(8)COMP-3

16. If PIC clause for a data item is PPPP999 and the value moved to the data-item
is 234 then the edited value taken is
a) 234
b) 2340000
c) 0000234
d) None of the above

17. The purpose of POINTER phrase in STRING command is


a) To specify the leftmost position within sending field where the first character
will be stored
b) To specify the leftmost position within receiving field where the first
transferred character will be stored
c) To specify the rightmost position within sending field where the first character
will be stored
d) To specify the rightmost position within receiving field where the first
transferred character will be stored

18. Consider the two statements:


1) WRITE print-rec FROM heading-9
2) MOVE heading-9 TO print-rec
WRITE print-rec
a) The output of both (1) and (2) will be same
b) The output of both (1) and (2) will be different
c) There is some syntax error in (1)
d) There is some syntax error in (2)

19. Level-number data-name1 REDEFINES data-name2


a) In the above statement the level-number of data-name1 and data-name2 must be
identical
b) In the above statement the level-number of data-name1 and data-name2 must be
different
c) In the above statement the level-number of data-name1 and data-name2 can be
different
d) The given syntax is incorrect

20. ADD CORRESPONDING identifier-1 TO identifier-2.


a) Identifier-1 and identifier-2 must not be data items with level numbers 66, 77,
88
b) Identifier-1 and identifier-2 can have a REDEFINES clause
c) Identifier-1 and identifier-2 can have a OCURS clause
d) All the above

Q1) What does the INITIALIZE verb do with alphanumeric items?


1) Set to Zero
2) Set to SPACES
3) 9’s will be inserted
4) None

Q3) What does SEARCH ALL do?


1) Linear search
2) Bubble sort
3) Binary search
4) None

Q5) What compiler option must be given for array bounds checking
1) NOSSRANGE
2) SSRANGE
3) DYNAM
4) LIB
Q7) Can you redefine an X(200) field with a field of X(100) ?
1) Yes
2) No
3) Can’t say

Q9) How is sign stored in a COMP field?


1) In the least significant bit
2) In the last nibble
3) Over punched with the numeric value
4) In the most significant bit

Q11) How many bytes will a S9(8) COMP field occupy?


1) 8 bytes
2) 4 bytes
3) 2 bytes
4) 5 bytes

Q15) What is SET TO TRUE all about?


1) Set value to condition name variable
2) Set value to related data item
3) Set value to index
4) None

Q17) What is the length of PIC 9. 99?


1) 3
2) 4
3) 5
4) 2

Q23) What is not valid statement


1) Add corresponding group-item1 to group-item2
2) Subtract corresponding group-item1 from group-item2
3) Move corresponding group-item1 to group-item2
5) Multiply corresponding group-item1 by group-item2
Q25) What is meant by S0C-07 system ABEND code?
1) Data exception
2) Memory violation
3) Division by zero
4) Missing DD name

Q28) Linkage Section comes under


1) Identification Division
2) Environment Division
3) Data Division
4) Procedure Division

Q31) Stop Run statement can be coded only_________ times in the source.
1) 1 time
2) 3 times
3) 2 times
4) As many as required

Q33) Following is a valid cobol user-defined word


1) DATA
2) 34B100-PARA1
3) -48B
4) GROSS PAY

Q35) COBOL stands for


1) Common business oriented language
2) Command business oriented language
3) Common business organized language
4) None

Q37) Consider the following PROCEDURE DIVISION statements

INSPECT ALPHA TALLYING COUNTER FOR LEADING “A”

Let the picture of ALPHA be X(20) and suppose its initial content is as follows
ANANDAbKUMARbMAI (where b denotes blank space).
If COUNTER (whose PICTURE is 99) originally contains 08 then after execution of the
INSPECT statement, COUNTER will have
1) 13
2) 09
3) 28
4) 5

Q39) Occurs clause cannot be used for


1) Level number 01
2) Level number 02
3) Level number 49
4) None

Q43) You have a string MAINFRAME. Which of the following statement will give you
‘MAIN’
1) MAINFRAME(1:4)
2) MAINFRAME(0:4)
3) MAINFRAME(:4)
4) MAINFRAME(4:)

Q47) What GOBACK will do if it is coded in subprogram


1) Returns control to the calling program
2) Returns control to the system
3) No effect
4) None

Q49) 01 TEST RECORD


02 FIRST PIC X(4)
02 SECOND REDEFINES FIRST PIC S9(4) COMP
will give
1) S0C7
2) Logic error
3) Compile error
4) No error

-----------------------------------------------------------------------------------
-----------------------------
------https://nhlink.net/mcq/100-top-cobol-multiple-choice-questions-and-answers
-----------------------------------------------------------------------------------
-----------------------------

21) Name the divisions which are not in the COBOL program.
A. IDENTIFICATION
B. ENVIRONMENT
C. FILE
D. DATA
E. WORKING
Answer: E

22) What level is used for RENAMES clause?


A. 66
B. 77
C. 88
D. 90
E. 01
Answer: B

23) How do you define a table/array in COBOL using INDEX?


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

B. 01 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX


C. 01 ARRAYS.
05 ARRAY1 PIC X(9) OCCURS INDEX BY 10 TIMES
D. 01 ARRAYS.
88 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX
E. None of the Above
Answer: B

24) Which mode of the opening is required when REWRITE is used?


A. UPDATE
B. OPEN
C. I-O
D. INPUT
E. REWRITE
Answer: C
25) Which clause can be used instead of checking for FILE STATUS = 10?
A. RECORD NOT FOUND
B. AT END
C. DUPLICATE RECORD
D. END OF FILE
E. AT SPACES
Answer: B

26) What are the access mode requirements of the START statement?
A. SEQUENTIAL
B. DYNAMIC
C. RELATIVE
D. INDEX
E. ALL OF THE ABOVE
Answer: B

27) What is comp-3 usage?


A. packed decimal
B. binary usage
C. Hex
D. Single precision floating point
E. None
Answer: A

28) In which section do sort description is given?


A. WORKING-STORAGE
B. FILE SECTION
C. CONTROL SECTION
D. LINKAGE SECTION
E. NONE
Answer: B

29) Which level is used for condition clause?


A. 77
B. 01
C. 05
D. 88
E. Any level can be used
Answer: D

30) Which statement is used to end the COBOL program?


A. STOP
B. END
C. STOP RUN
D. END RUN
E. None of the Above
Answer: C

-----------------------------------------------------------------------------------
-------------------
------------ Tutorials Point Mock Test
-----------------------------------------------------------------------------------
-------------------

Q 1 - Which data type is not available in COBOL?

A - Alphabetic (A)
B - Long (L)

C - Alphanumeric (X)

D - Numeric (9)

Q 2 - What does COBOL stand for?

A - Common Business Oriented Language

B - Common Business Object Language

C - Common Oriented Business Language

D - Common Object Business Language

Q 3 - Which is the mandatory division in COBOL program?

A - PROCEDURE DIVISION.

B - IDENTIFICATION DIVISION

C - DATA DIVISION

D - ENVIRONMENT DIVISION

Q 4 - How is sign stored in a COMP-3 field?

A - First Bit

B - Last Bit

C - First Nibble

D - Last Nibble

Q 5 - What will happen if you code GO BACK instead of STOP RUN in a stand alone
COBOL program?

A - Program will give run time error.

B - Program will go in infinite loop.

C - Program will execute normally.

D - Program will throw compilation error.

Q 6 - Which of the following file opening mode is invalid in COBOL?

A - APPEND

B - INPUT

C - OUTPUT

D - EXTEND

Q 7 - What is the maximum size of a numeric field we can define in COBOL?


A - 9(20)

B - 9(18)

C - 9(31)

D - 9(10)

Q 8 - What is the mode in which you will OPEN a file for writing?

A - OUTPUT

B - EXTEND

C - Either OUTPUT or EXTEND

D - INPUT-OUTPUT

Q 9 - What is 77 level used for?

A - Renames

B - Redefine

C - Group Item

D - Elementary Level

Q 10 - Where does AREA B in COBOL start from?

A - 01 to 07 columns

B - 12 to 72 columns

C - 08 to 11 columns

D - 73 to 80 columns

Q 11 - Where does the FILE-CONTROL paragraph appear?

A - Procedure Division

B - Environment Division

C - Identification Division

D - Data Division

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

A - No

B - Yes

Q 13 - What is the length of PIC 9.999?

A - 4
B - 6

C - 5

D - 3
Answer : C
Explanation

Length of PIC 9.999 is 5 as '.' takes 1 byte. So total 1 byte for '.' and 4 bytes
for 9.

Q 14 - How many times following loop will execute?

MOVE 5 TO X.
PERFORM X TIMES.
MOVE 10 TO X.
END-PERFORM.

A - 11

B - 5

C - 10

D - 15

Q 15 - Which cobol verb is used for updating a file?

A - READ

B - WRITE

C - UPDATE

D - REWRITE

Q 16 - Under which section we should make an entry in the program for a SORT file?

A - FD

B - SD

C - MD

D - None of these

Q 17 - How you will declare a Half Word Binary in program?

A - S9(8) COMP

B - S9(4) COMP

C - 9(8) COMP

D - 9(4) COMP

Q 18 - If 436 value is moved to a PP999 PIC clause, then what is edited value
taken?
A - .00436

B - 00436

C - 436

D - 43600

Q 19 - Where can we specify OCCURS clause?

A - Elementary Item

B - Group Item

C - Both A & B

D - None of these

Q 20 - Which utility is used for compiling COBOL program?

A - IKJEFT01

B - IGYCRCTL

C - IGYCTCRL

D - None of these

Q 21 - How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy?

A - 7 bytes

B - 8 bytes

C - 4 bytes

D - 10 bytes

Q 22 - What does SEARCH ALL do?

A - Linear search

B - Binary search

C - Sequential search

D - None of these

Q 23 - In which division, Linkage Section comes?

A - Identification Division

B - Environment Division

C - Data Division

D - Procedure Division

Q 24 - In which division, Input-Output section?


A - Identification Division

B - Environment Division

C - Data Division

D - Procedure Division

Q 25 - Which of the following statement will give you ‘Tutorials’ in TutorialsPoint


string?

A - TutorialsPoint(1:9)

B - TutorialsPoint(9)

C - TutorialsPoint(9:1)

D - TutorialsPoint(9:9)
-----------------------------------------------------------------------------------
--------------------------
1 B
2 A
3 B
4 D
5 B
6 A
7 B
8 C
9 D
10 B
11 B
12 B
13 C
14 B
15 D
16 B
17 B
18 A
19 C
20 B
21 B
22 B
23 C
24 B
25 A
-----------------------------------------------------------------------------------
---------------------------

Q 1 - What is the position of Area B in COBOL program?

A - 1-6 Columns

B - 8-11 Columns

C - 12-72 Columns
D - 72-80 Columns

Q 2 - What is the position of Area A in COBOL program?

A - 1-6 Columns

B - 8-11 Columns

C - 12-72 Columns

D - 72-80 Columns

Q 3 -How you will comment a line in a COBOL program?

A - Code asterisk(*) at 1st column.

B - Code asterisk(*) at 7th column.

C - Code hyphen(-) at 1st column.

D - Code hyphen(-) at 7th column.

Q 4 - Which of the alphanumeric literal is invalid?

A - 'COBOL12'

B - "COBOL12"

C - "COBOL''12"

D - 'COBOL12"

Q 5 - Which of the numeric literal is invalid?

A - 100

B - 10.9-

C - -10.9

D - 10.9

Q 6 - Which of the following word cannot be a user-defined COBOL word?

A - WS-ACCEPT

B - ACCEPT

C - WS-DISPLAY

D - TUTORIAL

Q 7 - Which level number we should use for RENAMES clause?

A - 77

B - 49

C - 66
D - 88

Q 8 - Which level number we should use for conditions?

A - 77

B - 88

C - 01

D - 66

Q 9 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUM1 PIC X(4) VALUE '15AB'.

PROCEDURE DIVISION.
MOVE 'XXXX' TO WS-NUM1
DISPLAY WS-NUM1.
STOP RUN.

A - 15AB

B - XXXX

C - Compilation error

D - Run time error

Q 10 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-ID PIC 9(5).

PROCEDURE DIVISION.
A000-FIRST-PARA.
INITIALIZE WS-ID REPLACING NUMERIC DATA BY 12345.
DISPLAY WS-ID.

STOP RUN.

A - 00000

B - 12345

C - Spaces

D - Compilation error
Q 11 - What is the output of the following code?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUM1 PIC 9(9).
01 WS-NUM2 PIC 9(6).

PROCEDURE DIVISION.
A000-FIRST-PARA.
MOVE 123456789 TO WS-NUM1.
MOVE WS-NUM1(3:6) TO WS-NUM2.

DISPLAY WS-NUM2

STOP RUN.

A - 456789

B - 000000

C - 123456

D - 345678

Q 12 - Moving a Numeric field to Alphabetic is legal?

A - Yes

B - No

Q 13 - Moving a Alphabetic field to Numeric is legal?

A - Yes

B - No

Q 14 - Moving a Numeric field to Alphanumeric is legal?

A - Yes

B - No

Q 15 - Moving a Alphabetic field to Alphanumeric is legal?

A - Yes

B - No

Q 16 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUMA PIC 9(9) VALUE 10.
01 WS-NUMB PIC 9(9) VALUE 10.
01 WS-NUMC PIC 9(9) VALUE 10.
01 WS-NUMD PIC 9(9) VALUE 100.
01 WS-NUME PIC 9(9) VALUE 10.

PROCEDURE DIVISION.
SUBTRACT WS-NUMA WS-NUMB WS-NUMC FROM WS-NUMD GIVING WS-NUME.
DISPLAY WS-NUME.

STOP RUN.

A - 000000100

B - 000000090

C - 000000070

D - 000000080

Q 17 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUMA PIC 9(9) VALUE 100.
01 WS-NUMB PIC 9(9) VALUE 15.
01 WS-NUMC PIC 9(2).
01 WS-REM PIC 9(2).

PROCEDURE DIVISION.
DIVIDE WS-NUMA BY WS-NUMB GIVING WS-NUMC REMAINDER WS-REM.
DISPLAY WS-NUMC ', ' WS-REM

STOP RUN.

A - 06, 10

B - 10, 06

C - Error

D - 100, 15

Q 18 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUM1 PIC 9(9) VALUE 10 .
01 WS-NUM2 PIC 9(9) VALUE 10.
01 WS-NUM3 PIC 9(9) VALUE 10.
01 WS-NUMA PIC 9(9) VALUE 50.
01 WS-NUMB PIC 9(9) VALUE 10.
01 WS-NUMC PIC 9(3).
PROCEDURE DIVISION.
COMPUTE WS-NUMC= (WS-NUM1 * WS-NUM2) - (WS-NUMA / WS-NUMB) + WS-NUM3.
DISPLAY WS-NUMC

STOP RUN.

A - 100

B - 105

C - Compilation error

D - Run time error

Q 19 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-DESCRIPTION.
05 WS-DATE1 VALUE '20140831'.
10 WS-YEAR PIC X(4).
10 WS-MONTH PIC X(2).
10 WS-DATE PIC X(2).
05 WS-DATE2 REDEFINES WS-DATE1 PIC 9(8).

PROCEDURE DIVISION.
DISPLAY WS-DATE2.

STOP RUN.

A - 00000000

B - 20140831

C - Compilation error

D - Run time error

Q 20 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-DESCRIPTION.
05 WS-NUM.
10 WS-NUM1 PIC 9(2) VALUE 20.
10 WS-NUM2 PIC 9(2) VALUE 56.
05 WS-CHAR.
10 WS-CHAR1 PIC X(2) VALUE 'AA'.
10 WS-CHAR2 PIC X(2) VALUE 'BB'.
10 WS-RENAME RENAMES WS-NUM2 THRU WS-CHAR2.

PROCEDURE DIVISION.
DISPLAY "WS-RENAME : " WS-RENAME.
STOP RUN.

A - 56AABB

B - Compilation Error

C - Space

D - Zeroes

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

A - 6

B - 4

C - 3

D - 2

Q 22 - How many bytes S9(6) USAGE IS COMP-3 will take?

A - 6

B - 3

C - 4

D - 7

Q 23 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUM1 PIC 9(9).
01 WS-NUM2 PIC 9(9).

PROCEDURE DIVISION.
A000-FIRST-PARA.
MOVE 25 TO WS-NUM1
MOVE 15 TO WS-NUM2

IF WS-NUM1 > WS-NUM2 THEN


DISPLAY 'IN LOOP 1 - IF BLOCK'
ELSE
DISPLAY 'IN LOOP 1 - ELSE BLOCK'
END-IF.

STOP RUN.

A - IN LOOP 1 - ELSE BLOCK

B - IN LOOP 1 - IF BLOCK

C - Error
D - None of these

Q 24 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUM PIC 9(3).
88 PASS VALUES ARE 041 THRU 100.
88 FAIL VALUES ARE 000 THRU 40.

PROCEDURE DIVISION.
A000-FIRST-PARA.
MOVE 65 TO WS-NUM.

IF PASS
DISPLAY 'Passed with ' WS-NUM ' marks'.

IF FAIL
DISPLAY 'FAILED with ' WS-NUM 'marks'.

STOP RUN.

A - Compilation error

B - Passed with 065 marks

C - FAILED with 065 marks

D - None of these

Q 25 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

PROCEDURE DIVISION.
A-PARA.
PERFORM DISPLAY 'A'
END-PERFORM.
PERFORM C-PARA THRU E-PARA.

B-PARA.
DISPLAY 'B'.
STOP RUN.

C-PARA.
DISPLAY 'C'.

D-PARA.
DISPLAY 'D'.

E-PARA.
DISPLAY 'E'.

A - ACDEB
B - ADCEB

C - DEBAC

D - DACEB
-----------------------------------------------------------------------------------
---------------------------
1 C
2 B
3 B
4 D
5 B
6 B
7 C
8 B
9 B
10 B
11 D
12 B
13 B
14 A
15 A
16 C
17 A
18 B
19 B
20 B
21 B
22 B
23 B
24 B
25 A
-----------------------------------------------------------------------------------
---------------------------

Q 1 - With test before is the default condition and it indicates that the condition
is checked before the execution of statements in a paragraph. Is this statement
true or false?

A - False

B - True

Q 2 - How many times following B-para loop will execute?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-A PIC 9 VALUE 0.

PROCEDURE DIVISION.
A-PARA.
PERFORM B-PARA VARYING WS-A FROM 1 BY 1 UNTIL WS-A=5
STOP RUN.
B-PARA.
DISPLAY 'IN B-PARA ' WS-A.

A - 5

B - 4

C - 3

D - 6

Q 3 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-A PIC 9 VALUE 2.

PROCEDURE DIVISION.
A-PARA.
DISPLAY 'A'
GO TO B-PARA.

B-PARA.
DISPLAY 'B'.
GO TO C-PARA D-PARA DEPENDING ON WS-A.

C-PARA.
DISPLAY 'C'.

D-PARA.
DISPLAY 'D'.
STOP RUN.

A - ABCD

B - ABD

C - BADC

D - DCBA

Q 4 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-CNT PIC 9(2) VALUE 0.
01 WS-STRING PIC X(15) VALUE 'AABCDACDAAEAAAF'.

PROCEDURE DIVISION.
INSPECT WS-STRING TALLYING WS-CNT FOR ALL 'A'.
DISPLAY WS-CNT

STOP RUN.
A - 09

B - 06

C - 08

D - 10

Q 5 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-STRING PIC X(15) VALUE 'ABCDACDADEAAAFF'.

PROCEDURE DIVISION.
INSPECT WS-STRING REPLACING ALL 'A' BY 'X'.
DISPLAY WS-STRING.

STOP RUN.

A - ABCDACDADEAAAFF

B - XBCDXCDXDEXXXFF

C - Compilation error

D - Run time error

Q 6 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-TABLE.
05 WS-A PIC A VALUE 'A' OCCURS 5 TIMES.

PROCEDURE DIVISION.
DISPLAY WS-TABLE.
STOP RUN.

A - A

B - AAAAA

C - Spaces

D - Error

Q 7 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-TABLE.
05 WS-A OCCURS 3 TIMES.
10 WS-B PIC A(2).
10 WS-C OCCURS 2 TIMES.
15 WS-D PIC X(3).

PROCEDURE DIVISION.
MOVE '12ABCDEF34GHIJKL56MNOPQR' TO WS-TABLE.
DISPLAY 'WS-C(3,1) : ' WS-C(3,1).

STOP RUN.

A - DEF

B - ABC

C - PQR

D - MNO

Q 8 - Set statement is used to change the index value. Set verb is used to
initialize, increment or decrement the index value. Is this statement true or
false?

A - False

B - True

Q 9 - Search is a binary search method, which is used to find elements inside the
table. Is this statement true or false?

A - True

B - False

Q 10 - Physical record is the information that exists on the external device and
Logical record is the information which is used by the program. Is this statement
true or false?

A - True

B - False

Q 11 - How records are stored & accessed in sequential file organization?

A - Relative address method

B - Sequential access method

C - Direct access method

D - Both B & C

Q 12 - How records are stored & accessed in indexed file organization?

A - Relative address method


B - Sequential access method

C - Direct access method

D - Both B & C

Q 13 - How records are stored & accessed in relative file organization?

A - Relative address

B - Sequentially

C - Directly

D - Both B & C

Q 14 - Which command is used to place the cursor on a specific record?

A - Open

B - Start

C - Read next

D - Write

Q 15 - Write verb is used to insert records in a file. Once the record is written,
it is no longer available in the record buffer. Is this statement true or false?

A - False

B - True

Q 16 - Rewrite verb is used to update the records. File should be opened in I-O
mode for rewrite operations. It can be used even if read operation is not
successful. Is this statement true or false?

A - True

B - False

Q 17 - For deleting a record, in which mode we should open the file?

A - Input-Output

B - Input

C - Output

D - Extend

Q 18 - If the values of variables in the called program are modified, then their
new values will reflect in the calling program. What type of call is this?

A - Call by content

B - Call by reference

C - None of these
Q 19 - If the values of variables in the called program are modified, then their
new values will not reflect in the calling program. What type of call is this?

A - Call by content

B - Call by reference

C - None of these

Q 20 - Static Call occurs when a program is compiled with the NODYNAM compiler
option. A static called program is loaded into storage at compile time. Is this
statement true or false.

A - False

B - True

Q 21 - Dynamic Call occurs when a program is compiled with the DYNAM and NODLL
compiler option. A dynamic called program is loaded into storage at runtime. Is
this statement true or false?

A - False

B - True

Q 22 - Which of the following is not a figurative constant?

A - High-Values

B - Comma

C - Zero

D - Spaces

Q 23 - Value clause is an optional clause which is used to initialize the data


items. The values can be numeric literal, alphanumeric literal, or figurative
constant. State whether true or false?

A - False

B - True

Q 24 - If usage clause is specified on a group, then all the elementary items will
have the same usage clause. State whether true or false?

A - False

B - True

Q 25 - If usage is display, data item is stored in ASCII format and each character
will take 1 byte. It is default usage. State whether true or false?

A - False

B - True
-----------------------------------------------------------------------------------
-------------------------
1 B
2 B
3 B
4 C
5 B
6 B
7 D
8 B
9 B
10 A
11 B
12 D
13 A
14 B
15 B
16 B
17 A
18 B
19 A
20 B
21 B
22 B
23 B
24 B
25 B
-----------------------------------------------------------------------------------
----------------------------

Q 1 - In which usage, data item is similar to Real or Float and is represented as a


single precision floating point number and internally data is stored in hexadecimal
format?

A - COMP

B - COMP-3

C - COMP-2

D - COMP-1

Q 2 - In which usage, data item is similar to Long or Double and is represented as


double precision floating point number and internally data is stored in hexadecimal
format?

A - COMP

B - COMP-3

C - COMP-2

D - COMP-1

Q 3 - In which usage, data item is stored in pack decimal format and each digit
occupies half a byte (1 nibble) and the sign is stored at the right most nibble?

A - COMP

B - COMP-3
C - COMP-2

D - COMP-1

Q 4 - Which verb is used to count or replace the characters in a string?

A - Count

B - Inspect

C - Replace

D - Add

Q 5 - Which option is used in Inspect verb to replace the string characters?

A - Count

B - Tallying

C - Replacing

D - Add

Q 6 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-STRING PIC A(30).
01 WS-STR1 PIC A(15) VALUE 'Tutorialspoint'.
01 WS-STR2 PIC A(7) VALUE 'Welcome'.
01 WS-STR3 PIC A(7) VALUE 'To AND'.
01 WS-COUNT PIC 99 VALUE 1.

PROCEDURE DIVISION.
STRING WS-STR2 DELIMITED BY SIZE
WS-STR3 DELIMITED BY SPACE
WS-STR1 DELIMITED BY SIZE
INTO WS-STRING
WITH POINTER WS-COUNT
ON OVERFLOW DISPLAY 'OVERFLOW!'
END-STRING.

DISPLAY 'WS-STRING : 'WS-STRING.

STOP RUN.

A - WelcomeTo

B - WelcomeToTutorialspoint

C - WelcomeTutorialspoint

D - WelcomeTopoint
Q 7 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-STRING PIC A(30) VALUE 'WELCOME TO TUTORIALSPOINT'.
01 WS-STR1 PIC A(7).
01 WS-STR2 PIC A(2).
01 WS-STR3 PIC A(15).
01 WS-COUNT PIC 99 VALUE 1.

PROCEDURE DIVISION.
UNSTRING WS-STRING DELIMITED BY SPACE
INTO WS-STR1, WS-STR2, WS-STR3
END-UNSTRING.

DISPLAY WS-STR2.

STOP RUN.

A - WelcomeTo

B - To

C - Tutorialspoint

D - point

Q 8 - Which statement we should not use in called program?

A - Linkage Section

B - Procedure Division Using

C - Stop Run

D - Exit Program

Q 9 - Two or more identically sequenced files are combined using Merge statement.
State whether true or false?

A - True

B - False

Q 10 - In which division we declare our variables?

A - PROCEDURE DIVISION.

B - IDENTIFICATION DIVISION

C - DATA DIVISION

D - ENVIRONMENT DIVISION

Q 11 - Which division provides information of external data sets used in the


program?
A - PROCEDURE DIVISION.

B - IDENTIFICATION DIVISION

C - DATA DIVISION

D - ENVIRONMENT DIVISION

Q 12 - In which division we write logic of the program?

A - PROCEDURE DIVISION.

B - IDENTIFICATION DIVISION

C - DATA DIVISION

D - ENVIRONMENT DIVISION

Q 13 - In which mode you will open the sequential file to append the data in the
end.

A - APPEND

B - INPUT

C - OUTPUT

D - EXTEND

Q 14 - Where does Column numbers in COBOL start from?

A - 01 to 07 columns

B - 12 to 72 columns

C - 08 to 11 columns

D - 73 to 80 columns

Q 15 - Where does Identification Area in COBOL starts from?

A - 01 to 07 columns

B - 12 to 72 columns

C - 08 to 11 columns

D - 73 to 80 columns

Q 16 - What is the length of a variable when usage is COMP-1?

A - 16

B - 2

C - 8

D - 4
Q 17 - What is the length of a variable when usage is COMP-2?

A - 2

B - 16

C - 4

D - 8

Q 18 - What is the length of PIC S9(7)V99 COMP-3?

A - 10

B - 9

C - 4

D - 5

Q 19 - What is the length of PIC S9(7) COMP?

A - 7

B - 6

C - 5

D - 4

Q 20 - What is the length of PIC 999V9?

A - 6

B - 5

C - 3

D - 4

Q 21 - 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?

A - True

B - False

Q 22 - Group items consist of one or more elementary items. Level number, Data
name, and Value clause (optional) are used to describe a group item. Group level
number is always 01. State whether true or false?

A - False

B - True

Q 23 - Decimal point position can be used with numeric data. Assumed position is
the position of decimal point and not included in the data. State whether true or
false?

A - False

B - True

Q 24 - Sign condition is used to check the sign of a numeric operand. It determines


whether a given numeric value is greater than, less than, or equal to ZERO. State
whether true or false?

A - False

B - True

Q 25 - Class condition is used to check if an operand contains only alphabets or


numeric data. Spaces are considered in ALPHABETIC, ALPHABETIC-LOWER, and
ALPHABETIC-UPPER. State whether true or false?

A - False

B - True
-----------------------------------------------------------------------------------
------------------------------
1 D
2 C
3 B
4 B
5 C
6 B
7 B
8 C
9 A
10 C
11 D
12 A
13 D
14 A
15 D
16 D
17 D
18 D
19 D
20 D
21 A
22 B
23 B
24 B
25 B
-----------------------------------------------------------------------------------
---------------------------------
------------------- Aired.in
-----------------------------------------------------------------------------------
---------------------------------

-----------------------------------------------------------------------------------
------------------------------------
---------------Mainframe gurukul
-----------------------------------------------------------------------------------
----------------------------------
Name the divisions in a COBOL program.

IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, DATA DIVISION, PROCEDURE


DIVISION.
What are the different data types available in COBOL?

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


What does the INITIALIZE verb do? �

Alphabetic, Alphanumeric fields & alphanumeric edited items are set to SPACES.

Numeric, Numeric edited items set to ZERO.

FILLER , OCCURS DEPENDING ON items left untouched.


What is 77 level used for ?

Elementary level item. Cannot be subdivisions of other items (cannot be


qualified), nor can they be subdivided themselves.

What is 88 level used for ?

For condition names.

What is level 66 used for ?

For RENAMES clause.

What does the IS NUMERIC clause establish ?

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

How do you define a table/array in COBOL?

01 ARRAYS.

05 ARRAY1 PIC X(9) OCCURS 10 TIMES.

05 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX.


Can the OCCURS clause be at the 01 level?

No.
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.
What is the difference between SEARCH and 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.
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).
What is binary search?

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

Must use compiler option SSRANGE if you want array bounds checking. Default is
NOSSRANGE.
How do you sort in a COBOL program? Give sort file definition, sort statement
syntax and meaning.

Syntax:

SORT file-1 ON ASCENDING/DESCENDING KEY key....

USING file-2

GIVING file-3.

USING can be substituted by INPUT PROCEDURE IS para-1 THRU para-2

GIVING can be substituted by OUTPUT PROCEDURE IS para-1 THRU para-2.

file-1 is the sort workfile and must be described using SD entry in FILE
SECTION.

file-2 is the input file for the SORT and must be described using an FD entry
in FILE SECTION and SELECT clause in FILE CONTROL.

file-3 is the outfile from the SORT and must be described using an FD entry in
FILE SECTION and SELECT clause in FILE CONTROL.

file-1, file-2 & file-3 should not be opened explicitly.

INPUT PROCEDURE is executed before the sort and records must be RELEASEd to the
sort work file from the input procedure.

OUTPUT PROCEDURE is executed after all records have been sorted. Records from
the sort work file must be RETURNed one at a time to the output procedure.
How do you define a sort file in JCL that runs the COBOL program?

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.
What are the two ways of doing sorting in a COBOL program? Give the formats.

See question 16.


Give the format of USING and GIVING in SORT statement. What are the
restrictions with it?

See question 16. Restrictions - Cannot massage records, canot select records to
be sorted.
What is the difference between performing a SECTION and a PARAGRAPH?

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.


What is the use of EVALUATE statement?

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.
What are the different forms of EVALUATE statement?

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
How do you come out of an EVALUATE statement?

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.
In an EVALUATE statement, can I give a complex condition on a when clause?

Yes.
What is a scope terminator? Give examples.

Scope terminator is used to mark the end of a verb e.g. EVALUATE, END-EVALUATE;
IF, END-IF.
How do you do in-line PERFORM?

PERFORM ... ...

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

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

What does EXIT do ?

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


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

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.


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

Yes.
What do you do to resolve SOC-7 error?

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.
How is sign stored in Packed Decimal fields and Zoned Decimal fields?

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.
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...
How is sign stored in a COMP field ?

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


What is the difference between COMP & COMP-3 ?

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


What is COMP-1? COMP-2?

COMP-1 - Single precision floating point. Uses 4 bytes.

COMP-2 - Double precision floating point. Uses 8 bytes.


How do you define a variable of COMP-1? COMP-2?

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


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

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.


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

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


How many bytes will a S9(8) COMP field occupy ?

4 bytes.
What is the maximum value that can be stored in S9(8) COMP?

99999999
What is COMP SYNC?

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.


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

In COBOL II: 16777215


How do you reference the following file formats from COBOL programs:

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).
What are different file OPEN modes available in COBOL?

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


What is the mode in which you will OPEN a file for writing?

OUTPUT, EXTEND
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.
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.


What is file status 92?

Logic error. e.g., a file is opened for input and an attempt is made to write
to it.
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.
What is Static,Dynamic linking ?

In static linking, the called subroutine is link-edited into the calling


program , while in dynamic linking, the subroutine & the main program will exist as
separate load modules. You choose static/dynamic linking by choosing either the
DYNAM or NODYNAM link edit option. (Even if you choose NODYNAM, a CALL identifier
(as opposed to a CALL literal), will translate to a DYNAMIC call).

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.
What is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY)? ( applicable to only

MVS/ESA Enterprise Server).

These are compile/link edit options.

AMODE - Addressing mode. RMODE - Residency mode.

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 compiler option would you use for dynamic linking?

DYNAM.
What is SSRANGE, NOSSRANGE ?

These are compiler options w.r.t subscript out of range checking. NOSSRANGE is
the default and if chosen, no run time error will be flagged if your index or
subscript goes out of the permissible range.
How do you set a return code to the JCL from a COBOL program?

Move a value to RETURN-CODE register. RETURN-CODE should not be declared in


your program.
How can you submit a job from COBOL programs?

Write JCL cards to a dataset with

//xxxxxxx SYSOUT=(A,INTRDR) where 'A' is output class, and dataset should be


opened for output in the program. Define a 80 byte record layout for the file.
What are the differences between OS VS COBOL and VS COBOL II?

OS/VS Cobol pgms can only run in 24 bit addressing mode, VS Cobol II pgms can
run either in 24 bit or 31 bit addressing modes.

Report writer is supported only in OS/VS Cobol.

USAGE IS POINTER is supported only in VS COBOL II.

Reference modification eg: WS-VAR(1:2) is supported only in VS COBOL II.

EVALUATE is supported only in VS COBOL II.

Scope terminators are supported only in VS COBOL II.

OS/VS Cobol follows ANSI 74 stds while VS COBOL II follows ANSI 85 stds.

Under CICS Calls between VS COBOL II programs are supported.


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

DB2 precompiler (if embedded sql used), CICS translator (if CICS pgm), Cobol
compiler, Link editor.

If DB2 program, create plan by binding the DBRMs.


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.


-----------------------------------------------------------------------------------
-------------------------------

You might also like