Cobol Quiz
Cobol Quiz
======================================
COBOL
===================================================================================
======================================
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?
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
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?
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
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
STOP RUN.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--------------------------------------------------------
Q26 - What is the mode in which you will OPEN a file for writing?
A - OUTPUT
B - 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.
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
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
Option B
Option A
OPtion B
Option C
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
Option B
Option B
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
Option B
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
OPtion D
Option C
Option A
Option C
===================================================================================
===================================================================================
============================================================================
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
8) What is the mode in which you will OPEN a file for writing?
a. OUTPUT
b. INPUT
c. EXTEND
d. a & c
16) The____ statement release the resources which are assigned to that file
a. STOP RUN
b. EXIT.
c. WRITE
d. END
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
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)
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.
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
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.
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
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
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
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) –
-----------------------------------------------------------------------------------
------------------------------
2. The difference between ‘*’ and ‘/’ is that in case of ‘/’ the comment line will
be printed after page ejection.
a) True
b) False
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
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
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
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
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
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
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:)
-----------------------------------------------------------------------------------
-----------------------------
------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
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
-----------------------------------------------------------------------------------
-------------------
------------ Tutorials Point Mock Test
-----------------------------------------------------------------------------------
-------------------
A - Alphabetic (A)
B - Long (L)
C - Alphanumeric (X)
D - Numeric (9)
A - PROCEDURE DIVISION.
B - IDENTIFICATION DIVISION
C - DATA DIVISION
D - ENVIRONMENT DIVISION
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 - APPEND
B - INPUT
C - OUTPUT
D - EXTEND
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
D - INPUT-OUTPUT
A - Renames
B - Redefine
C - Group Item
D - Elementary Level
A - 01 to 07 columns
B - 12 to 72 columns
C - 08 to 11 columns
D - 73 to 80 columns
A - Procedure Division
B - Environment Division
C - Identification Division
D - Data Division
A - No
B - Yes
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.
MOVE 5 TO X.
PERFORM X TIMES.
MOVE 10 TO X.
END-PERFORM.
A - 11
B - 5
C - 10
D - 15
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
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
A - Elementary Item
B - Group Item
C - Both A & B
D - None of these
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
A - Linear search
B - Binary search
C - Sequential search
D - None of these
A - Identification Division
B - Environment Division
C - Data Division
D - Procedure Division
B - Environment Division
C - Data Division
D - Procedure Division
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
-----------------------------------------------------------------------------------
---------------------------
A - 1-6 Columns
B - 8-11 Columns
C - 12-72 Columns
D - 72-80 Columns
A - 1-6 Columns
B - 8-11 Columns
C - 12-72 Columns
D - 72-80 Columns
A - 'COBOL12'
B - "COBOL12"
C - "COBOL''12"
D - 'COBOL12"
A - 100
B - 10.9-
C - -10.9
D - 10.9
A - WS-ACCEPT
B - ACCEPT
C - WS-DISPLAY
D - TUTORIAL
A - 77
B - 49
C - 66
D - 88
A - 77
B - 88
C - 01
D - 66
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
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
A - Yes
B - No
A - Yes
B - No
A - Yes
B - No
A - Yes
B - No
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
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
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
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
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
A - 6
B - 4
C - 3
D - 2
A - 6
B - 3
C - 4
D - 7
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
STOP RUN.
B - IN LOOP 1 - IF BLOCK
C - Error
D - None of these
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
D - None of these
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
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
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
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
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
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
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
D - Both B & C
D - Both B & C
A - Relative address
B - Sequentially
C - Directly
D - Both B & C
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
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
A - High-Values
B - Comma
C - Zero
D - Spaces
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
-----------------------------------------------------------------------------------
----------------------------
A - COMP
B - COMP-3
C - COMP-2
D - COMP-1
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
A - Count
B - Inspect
C - Replace
D - Add
A - Count
B - Tallying
C - Replacing
D - Add
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.
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
A - Linkage Section
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
A - PROCEDURE DIVISION.
B - IDENTIFICATION DIVISION
C - DATA DIVISION
D - ENVIRONMENT DIVISION
B - IDENTIFICATION DIVISION
C - DATA DIVISION
D - ENVIRONMENT DIVISION
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
A - 01 to 07 columns
B - 12 to 72 columns
C - 08 to 11 columns
D - 73 to 80 columns
A - 01 to 07 columns
B - 12 to 72 columns
C - 08 to 11 columns
D - 73 to 80 columns
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
A - 10
B - 9
C - 4
D - 5
A - 7
B - 6
C - 5
D - 4
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
A - False
B - True
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.
Alphabetic, Alphanumeric fields & alphanumeric edited items are set to SPACES.
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 - .
01 ARRAYS.
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 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:
USING file-2
GIVING file-3.
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.
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. 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.
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?
END-EVALUATE END-EVALUATE
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?
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.
CONTINUE is like a null statement (do nothing) , while NEXT SENTENCE transfers
control to the next sentence (!!)
(A sentence is terminated by a period)
Yes. Redefines just causes both fields to start at the same location. For
example:
Yes.
What do you do to resolve SOC-7 error?
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 ?
Will take 4 bytes. Sign is stored as hex value in the last nibble.
4 bytes.
What is the maximum value that can be stored in S9(8) COMP?
99999999
What is COMP SYNC?
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
KSDS VSAM file - Use ORGANISATION IS INDEXED, RECORD KEY IS, ALTERNATE RECORD
KEY IS
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?
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 ?
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
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?
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.
OS/VS Cobol follows ANSI 74 stds while VS COBOL II follows ANSI 85 stds.
DB2 precompiler (if embedded sql used), CICS translator (if CICS pgm), Cobol
compiler, Link editor.