Professional Documents
Culture Documents
Introduction
The following are a series of COBOL Examination questions together with the answers.
The questions are in 2 sections. The first section is concerned with regular Procedural COBOL. The
second section addresses Object Oriented COBOL.
PERFORM 210-READ-EMPLOYEE-RECORD.
IF NOT EMP-EOF
EVALUATE TRUE
WHEN EL-GROSS-PAY < 1 OR
EL-PAY-RATE > 45
DISPLAY 'INVALID PAY CLASS'
WHEN OTHER
MOVE EL-PAY-RATE TO RATE-SUB
COMPUTE GROSS-PAY ROUNDED = EM-HOURS-WORKED *
PAY-RATE (RATE-SUB)
END-EVALUATE.
PERFORM 220-PRINT-EMPLOYEE-LINE
END-IF.
1
COBOL Exam Answers
2
COBOL Exam Answers
a. 3
b. 4
c. 5
d. 6 YES
10. Where does AREA B in COBOL extend from?
a. 8-11
b. 8-16
c. 12-72 YES
11. The FILE-CONTROL paragraph in a COBOL program appears in
a. Input-Output Section in Environment Division YES
b. File Section in Data Division
c. Procedure Division, it can only be a user-defined paragraph
d. Configuration Section in Environment Division
12. Program-id is a paragraph name in IDENTIFICATION division?
a. TRUE YES
b. FALSE
13. If the Procedure Division of a program contains the statement:
WRITE MASTER-REC
This suggests that the OPEN statement for this file must NOT be:
a. OPEN INPUT YES
b. OPEN I-O
c. OPEN EXTEND
d. OPEN OUTPUT
14. ROUNDED precedes the ON SIZE ERROR?
a. TRUE YES
b. FALSE
15. A Numeric data item in COBOL can have at most how many digits?
a. 10
b. 160
c. 18 YES
d. 32
e. Almost unlimited
16. A Non Numeric data item in COBOL can have at most how many characters?
a. 10
b. 160
c. 18
d. 32
e. Almost unlimited YES
17. A 01 level cannot have PIC clause?
a. TRUE
b. FALSE YES
18. Which of the following are not valid modes of opening an INDEXED file
a. OPEN INPUT
b. OPEN OUTPUT
c. OPEN I-O
3
COBOL Exam Answers
4
COBOL Exam Answers
28. In an indexed file, the START statement enables the programmers to start processing from
any record position.
a. TRUE YES
b. FALSE
29. The UNSTRING verb is used to transfer data from several sources to one receiving field.
a. TRUE
b. FALSE YES
30. The STRING verb can be used to transfer characters from one alphanumeric field to another
alphanumeric field starting at some particular position in the receiving field
a. TRUE
b. FALSE YES
31. If the DELIMITED BY SIZE phrase is used with STRING verb, the transfer of characters into the
receiving field stops as soon as a blank is encountered in the sending field
a. TRUE
b. FALSE YES
32. The INSPECT statement can be used to check whether the value in a data name is numeric
a. TRUE
b. FALSE YES
33. UNSTRING “ABC” INTO FIELD-1.
Indicate which one of the following is correct.
a. There will be a syntax error, as the statement does not contain any DELIMITED BY
phrase.
b. There will be a syntax error, as the sending string must be identifier and not a literal.
YES
c. The statement is correct and after the execution of the statement field-1 will contain
the three characters “ABC” from the left-most position and the remaining positions
of field-1 will remain unchanged
d. The statement is correct and after the execution of the statement field-1 will contain
the three characters “ABC” from the left-most position and the remaining positions
of field-1 will get filled with spaces.
34. Which of the following statements allows more than 2 alternative paths of execution?
a. Evaluate statements YES
b. if statements
c. perform statement
d. copy statement
35. PERFORM PARA-A VARYING A FROM 1 BY 1 UNTIL A = 13.
How many times would the statements in PARA-A execute?
a. 11
b. 12 YES
c. 13
d. 14
36. How do you define a variable of COMP-3?
a. 01 WS-VAR PIC S9(4) COMP-3. YES
b. 01 WS-VAR USAGE COMP-3.
c. 01 WS-VAR COMP-3.
5
COBOL Exam Answers
6
COBOL Exam Answers
44. Which files will be closed at run time with the following code:
CLOSE TBLFILE.
EMPFILE
PAYLIST.
a. All 3 files
b. Just TBLFILE
c. TBLFILE and EMPFILE
d. None will close since there is a syntax error. YES
45. If WS-OLD and WS-NEW are both PIC X(10), what will be the value in WS-NEW if WS-OLD
contains ‘ABCDEFG’
move WS-OLD(4:3) to WS-NEW
a. Nothing, since the MOVE contains a syntax error
b. 444
c. ABC
d. DEF YES
46. After the above move, is WS-NEW greater than or less than WS-OLD
a. WS-NEW is greater than WS-OLD YES
b. WS-OLD is greater than WS-NEW
47. With the following data division definitions:
b.
7
COBOL Exam Answers
c. 21.6 YES
d. 216.00
49. With the following data division definitions, what will num-data2 contain after the 2
procedure statements?
8
COBOL Exam Answers
9
COBOL Exam Answers
62. You can use the same data name more than once in a program, if the data name is defined
at level below level 01
a. TRUE YES
b. FALSE
63. Which of these COBOL lines will cause syntax errors at compilation time?
a. if valid-rec and in-name unequal spaces
b. perform valid-record.
c. else YES
d. perform invalid-record
e. end-if YES
64. When reading from an indexed file, is the following syntax valid:
move ‘1111’ to record-key
read infile key is record-key
at end
perform end-of-file-routine
end-read
a. TRUE
b. FALSE YES
65. When reading sequentially from an indexed file, is the following syntax valid:
move ‘1111’ to record-key
start infile key > record-key
invalid key
perform not-found
not invalid key
read infile next
end-start
a. TRUE YES
b. FALSE
66. Post 1985, which of the following phrases is valid when testing if two data items have not
got the same value:
a. DATA-1 NOT EQUAL TO DATA-2
b. DATA-1 NOT = DATA-2
c. DATA-1 UNEQUAL DATA-2
d. DATA-1 <> DATA-2
e. All of the above a. thru d. YES
f. None of the above a. thru d.
67. Assuming that WS-DATA is working storage data and FS-DATA is a level 01 record in a file, is
the following COBOL statement valid?
WRITE WS-DATA TO FS-DATA
a. TRUE
b. FALSE YES
68. Assuming that WS-DATA is working storage data and FS-DATA is a level 01 record in a file, is
the following COBOL statement valid?
WRITE FS-DATA FROM WS-DATA
a. TRUE YES
b. FALSE
10
COBOL Exam Answers
69. Under an FD statement the file record definition cannot contain value clauses but it can
contain level 88 condition names:
a. TRUE YES
b. FALSE
70. The following 88 syntax is valid?
88 VALID-DATA PIC 9(4) VALUE 20 THRU 2000.
a. TRUE
b. FALSE YES
71. Which of the following is true?
a. When a program A calls program B, the data names in the call statement must be
identical to the data names in the linkage section of the called program.
b. When a program A calls program B, the data names in the call statement must be in
the same order as the data names in the linkage section of the called program. YES
c. Both a. and b.
d. Neither a. not b.
72. What would be the output to the screen after executing the following code:
PROCEDURE DIVISION.
PROG.
PERFORM PARA-1 THRU PARA-3
STOP RUN.
PARA-1.
DISPLAY "1"
GO TO PARA-4.
PARA-2.
DISPLAY "2".
PARA-3.
DISPLAY "3".
PARA-4.
DISPLAY "4".
PARA-5.
DISPLAY "5"
GO TO PARA-2.
a. 1,2,3,4,5
b. 1,2,3,1,4,5
c. 1,4,5,2,3 YES
d. 1,4,5,1,2,3
73. This program causes an infinite loop?
PROCEDURE DIVISION.
PROG.
PERFORM PARA-1
STOP RUN.
PARA-1.
DISPLAY "1"
GO TO PARA-4.
PARA-2.
DISPLAY "2".
PARA-3.
DISPLAY "3".
PARA-4.
DISPLAY "4".
PARA-5.
DISPLAY "5"
GO TO PARA-2.
11
COBOL Exam Answers
a. TRUE YES
b. FALSE
74. This program causes an infinite loop?
PROCEDURE DIVISION.
PROG.
PERFORM PARA-2
STOP RUN.
PARA-1.
DISPLAY "1"
GO TO PARA-4.
PARA-2.
DISPLAY "2".
PARA-3.
DISPLAY "3".
PARA-4.
DISPLAY "4".
PARA-5.
DISPLAY "5"
GO TO PARA-2.
a. TRUE
b. FALSE YES
75. Has the following code got a problem?
process-file.
move 0 to file-flag
open input my-file
read my-file
perform until file-flag = 1
display my-file-record
read my-file
end-perform
close my-file.
a. Problem YES – the file-flag is not set to 1 at the end of the file
b. No Problem
76. Has the following code got a problem?
process-file.
move 0 to file-flag
open input my-file
perform until file-flag = 1
display my-file-record
read my-file at end
move 1 to file-flag
end-read
end-perform
close my-file.
a. Problem YES – the first time in the loop the file has not been read so the first
display will display garbage
b. No Problem
77. Which of these lines of code have a syntax error?
01 MY-DATA PIC X(20).
03 MY-FNAME PIC X(10)
03 MY-SNAME PIC X(10).
a. First line
12
COBOL Exam Answers
13
COBOL Exam Answers
DISPLAY ‘KEY OK’
END-START
a. VALID YES
b. INVALID
83. On an indexed file MY-FILE with the prime key CUST-NO is the following syntax valid?
READ MY-FILE NEXT KEY IS CUST-NO
INVALID KEY
DISPLAY ‘KEY NOT FOUND’
END-READ
a. VALID
b. INVALID YES
84. On an indexed file MY-FILE with the prime key CUST-NO and alternate keys CUST-FNAME
and CUST-SNAME is the following syntax valid?
MOVE ‘JONES’ TO CUST-SNAME
READ MY-FILE ALTERNATE KEY IS CUST-SNAME
INVALID KEY
DISPLAY ‘KEY NOT FOUND’
END-READ
a. VALID
b. INVALID YES
85. On an indexed file MY-FILE with the prime key CUST-NO and alternate keys CUST-FNAME
and CUST-SNAME is the following syntax valid?
MOVE ‘FRED’ TO CUST-FNAME
READ MY-FILE KEY IS CUST-FNAME
INVALID KEY
DISPLAY ‘KEY NOT FOUND’
NOT INVALID KEY
DISPLAY CUST-FNAME ‘ FOUND’
END-READ
a. VALID YES
b. INVALID
86. On an indexed file MY-FILE with the prime key CUST-NO and alternate keys CUST-FNAME
and CUST-SNAME; and record name MY-RECORD is the following syntax valid?
MOVE 1234 TO CUST-NO
WRITE MY-RECORD KEY IS CUST-NO
INVALID KEY
DISPLAY ‘WRITE FAILED’
NOT INVALID KEY
DISPLAY ‘WRITE SUCESSFUL’
END-READ
a. VALID YES
b. INVALID
87. A data item WS-NUMBER is defined in working-storage section as $$$,$$$.99. If the value -
2345.67 is moved to it, what will the display look like after DISPLAY WS-NUMBER
a. $2,345.67 YES
b. –$2,345.67
c. $ 2,345.67
d. -2,345.67$
14
COBOL Exam Answers
b. MSIL YES
c. RTS
d. CLR
e. JCM
89. The following code syntax is valid:
Method-ID Calculate.
Procedure Division.
Compute CircleArea = 3.14 * Radius * Radius
Compute Circumference = 6.28 * Radius
.
End Class.
End Method.
a. TRUE
b. FALSE YES – The end-class is ahead of the end-method
90. Which of the following code syntax is valid?
1. Invoke type CircleCalculations::New()
Returning circleObject
15
COBOL Exam Answers
b.
99. In the definition of Object Instance data, which of the following is valid syntax?
a. 01 Circumference pic 999v9 property set.
b. 01 Circumference pic 999v9 property no set. YES
16
COBOL Exam Answers
17