You are on page 1of 17

COBOL Exam Answers

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.

Section 1 – Procedural COBOL


1. Which of the following is an INCORRECT specification for a data-name?
a. var-var1
b. data1
c. two
d. all YES (ALL is a reserved word)
2. What is the result of the following?

a. PARA-1 will be performed YES


b. PARA-2 will be performed
c. Both PARA-1 and PARA-2 will be performed.
d. Compile error for incorrect use of OTHER sentence
3. Which of the following PIC clauses is invalid as a floating symbol?
a. +
b. $
c. S YES
d. –
4. What will happen to the code below when the end of file is reached:

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

a. Nothing, because the code has a syntax error YES


b. It will display ‘INVALID PAY CLASS’ and then print the employee-line
c. It will calculate the gross-pay and then print the employee-line
5. What is the result of the following?

a. PARA-1 will be performed


b. PARA-2 will be performed
c. Both PARA-1 and PARA-2 will be performed.
d. PARA-3 will be performed YES
6. Which of the following is an invalid paragraph name?
a. A-1
b. 999X
c. A+1 YES
d. ZZ9
7. Which of the following is correct definition of figurative constant in COBOL?
a. Constants that are represented as alphanumeric text also known as non-numeric
literals.
b. Constants that are represented in terms of digits, also known as literals
c. Data names that are initialized to specific values in DATA DIVISION and retain those
values throughout the execution of the program.
d. Reserved words that are used as substitutes for certain special constants - numeric
and alphanumeric YES
8. Where does AREA A in COBOL extends from?
a. 8-16
b. 8-11 YES
c. 12-72
d. 8-10
9. According to the given declarations in Data Division. How many elementary items are
described below?

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

d. OPEN INDEXED YES


19. Which of the following is true about the file which is referenced in a DELETE statement
a. It must be opened in INPUT mode
b. It must be opened in OUTPUT mode
c. It must be opened in I-O mode YES
d. It must be opened in EXTEND mode
20. Which of the following is not a PROCEDURE DIVISION verb
a. START
b. SEEK YES
c. RERUN YES
d. DELETE
e. REWRITE
f. INSERT YES
21. Which of the statements may indicate DUPLICATE alternative key warning if it occurs in case
of an INDEXED ORGANISATION without DUPLICATE phrase
a. READ
b. REWRITE
c. WRITE YES
d. DELETE
22. In case of a data file, the ACCESS MODE clause must always be specified.
a. TRUE
b. FALSE YES
23. Which statement(s) are true about the FILLER clause?
a. FILLER can only be used in working-storage section.
b. FILLER can be used in any of the data division sections YES
c. The word FILLER can be replaced with spaces. YES
d. You can move data into a FILLER in procedure division
e. None of the above
24. A READ statement can have AT END clause and INVALID KEY clause, but both must not
appear simultaneously.
a. TRUE YES
b. FALSE
25. What is the difference between SEARCH and SEARCH ALL?
a. SEARCH requires the table to be sorted
b. SEARCHALL requires the table to be sorted YES
c. There is no difference
26. With a READ statement either AT END clause or INVALID KEY clause must be specified
a. TRUE
b. FALSE YES
27. The name of a program is contained in:
a. Data Division
b. Procedure Division
c. Identification Division YES
d. Environment Division

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

d. 01 WS-VAR COMP-3 USAGE.


37. There is a file whose ORGANISATION is INDEXED. You want to read the records from the file
in RANDOM fashion as well as sequentially, then which of the access mode would you
specify?
a. SEQUENTIAL
b. RANDOM
c. DYNAMIC YES
d. ACCESS MODE has nothing to do with it
38. In File-Control what are the 2 names
a. The names of the 2 data files
b. The relationship between internal file name and external file name YES
c. The data items used by the file
d. The procedure names to use in paragraphs
39. Consider the following piece of code

what will be the content of AMOUNT-1?


a. 50
b. 100
c. 0
d. Unpredictable YES
40. A=10, B=5, C=10, D=5, E=0. What will be the value of E after the following statement:
ADD A, B TO C, D GIVING E.
a. 15
b. 10
c. Runtime Error
d. Syntax Error YES
41. What is the result of the following? DIVIDE A INTO B GIVING C
a. C=A/B
b. The remainder of B/A is stored in C
c. C=B/A YES
d. The remainder of A/B is stored in C
42. Which of the following is incorrect
a. SUBTRACT A B C FROM D E F
b. SUBTRACT A B C FROM D E GIVING F G YES
c. SUBTRACT A FROM D, B FROM E, C FROM F YES
d. SUBTRACT A FROM B GIVING D E F.
43. What is the linkage section?
a. It is must for called program

6
COBOL Exam Answers

b. It is must for calling program


c. Used for displaying messages in sub program
d. Temporary storage for called program YES

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:

which of the following is valid COBOL syntax?


a.

b.

c. Both of these YES


d. Neither of these
48. With the following data division definitions, what will num-data2 contain after the 2
procedure statements?

a. Undefined, since num-data2 is not signed


b. -21.6

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?

a. Undefined, since num-data2 is not signed


b. -1234
c. -2345
d. 1234
e. 2345 YES
50. When creating a mixed language application between C# (or VB) and COBOL, you need to
put the C# and COBOL in the same project?
a. TRUE
b. FALSE YES
51. In the following code, what is the sequence of paragraphs at execution time?

a. PROG, PARA-1, PARA-2, PARA-3


b. PROG, PARA-1. PARA-4, PARA-5, PARA-3 YES
c. PROG, PARA-2, PARA-3
52. Which of the following statements is true:
a. In COBOL you can only PERFORM Sections
b. In COBOL you can only PERFORM Paragraphs
c. In COBOL you can only use GO TO to move the execution point to a Paragraph
d. In COBOL you can only use GO TO to move the execution point to a Section
e. All the above
a. None of the above YES
53. Assuming you have a sequential file defined by the following Select statement:
SELECT INFILE ASSIGN INNAME
Which of the following clauses is valid:

8
COBOL Exam Answers

a. FILE STATUS IS FILE STATUS.


b. FILE-STATUS IS FILE-STATUS.
c. FILE STATUS IS FILE-STATUS. YES
d. FILE-STATUS IS FILE STATUS.
e. None of the above.
54. In data division which of the following sections allow you to put VALUE clauses
a. WORKING-STORAGE SECTION. YES
b. FILE SECTION.
c. LINKAGE SECTION.
55. When you MOVE a pic x(20) data field to a pic x(10) data field, which of these is true?
a. The receiving pic x(10) field will contain the first 10 characters from the sending
pic x(20) field. YES
b. The receiving pic x(10) field will contain the last 10 characters from the sending
pic x(20) field.
56. When you MOVE a pic x(10) data field to a pic x(20) data field, which of these is true?
a. The receiving pic x(20) field will contain the 10 characters from the sending
pic x(10) field left aligned with the remaining 10 characters left blank. YES
b. The receiving pic x(20) field will contain the 10 characters from the sending
pic x(10) field left aligned with the remaining 10 characters left unchanged from
whatever was there before.
c. The receiving pic x(20) field will contain the 10 characters from the sending
pic x(10) field right aligned with the remaining 10 characters left blank
d. The receiving pic x(20) field will contain the 10 characters from the sending
pic x(10) field right aligned with the remaining 10 characters left unchanged from
whatever was there before.
57. The figurative constants ZERO, ZEROS, ZEROES all mean the same thing?
a. TRUE YES
b. FALSE
58. The use of single quotes ' and double quotes " in the definition of a literal have exactly the
same meaning?
a. TRUE YES
b. FALSE
59. The use of STOP ' ' causes which of the following to happen:
a. The program terminates
b. The program waits for a user to press the Enter key YES
c. The program waits for a user to press the Enter key and then terminates.
60. You can define the same data name more than once in a program.
a. TRUE YES
b. FALSE
61. You can define the same data name more than once in a program, if the data name is
defined at level 01
a. TRUE
b. FALSE YES

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

b. First and second line YES


c. Third line
d. All 3 lines
e. None of them.

78. The following code syntax is valid:


PERFORM MY-UPDATE VARYING MY-IND FROM 1 BY 1 UNTIL MY-IND > 10
READ IN-FILE
END-PERFORM
a. TRUE
b. FALSE YES - the PERFORM is not an in-line perform therefore END-PERFORM will fail
79. Is the following EVALUATE syntax valid
EVALUATE TRUE ALSO WS-DATA
WHEN A = B ALSO ‘A’
PERFORM PROC-1
WHEN B = C ALSO ‘B’
PERFORM PROC-2
WHEN OTHER ALSO OTHER
PERFORM PROC-3
END-PERFORM
a. Valid YES
b. Invalid
80. Is the following IF syntax valid
IF A = B
PERFORM PROC-1
ELSE
PERFORM PROC-2.
END-IF
a. Valid
b. Invalid YES – END-IF does not work because of the period on the line above
81. If A is the same value as B, what gets displayed on the screen after the following code is
executed?
IF A = B
DISPLAY ‘HELLO ’
DISPLAY ‘FRED’
ELSE
DISPLAY ‘GOODBYE ’.
DISPLAY ‘JIM’.
a. HELLO
FRED
b. GOODBYE
JIM
c. HELLO
FRED
JIM YES
d. The code does not compile
82. On an indexed file MY-FILE, with the prime key CUST-NO is the following syntax valid?
START MY-FILE KEY IS CUST-NO > 67
INVALID KEY
DISPLAY ‘KEY NOT FOUND’
NOT INVALID KEY

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$

Section 2 – Object COBOL


88. What is the name of the .NET intermediate language?
a. .NET IL

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

2. set circleObject to CircleCalculations::New()

a. The first one


b. The second one
c. Both YES
d. Neither
91. The declaration of a CircleObject is:
circleObject type CircleCalculations.
a. TRUE YES
b. FALSE
c. Is the following EVALUATE syntax valid
EVALUATE TRUE ALSO WS-DATA
WHEN A = B ALSO ‘A’
PERFORM PROC-1
WHEN B = C ALSO ‘B’
PERFORM PROC-2
WHEN ‘B’ ALSO D = E
PERFORM PROC-3
END-PERFORM
c. Valid
92. Invalid YES

What is the correct syntax for describing an Object Instance item:


a. 01 circleObject is CircleCalculations.
b. 01 circleObject type CircleCalculations. YES
c. 01 circleObject pic 999 type CircleCalculations.
d. 01 circleObject pic X(20) type CircleCalculations.
93. Which of the following can be the correct syntax for creating a new object:
a. Set circleObject to CircleCalculations::New()
b. Set circleObject to type CircleCalculations::New()YES
c. Invoke type CircleCalculations::New() Returning circleObject YES
d. Move CircleCalculations::New()to circleObject

15
COBOL Exam Answers

94. A client to a Web Service can be:


a. A Web Form
b. A Win Form
c. A Console Application
d. Any of these YES
e. None of these
95. If you want to have an implicit get method on an object instance data item, you need to
define the property clause alongside the instance data definition. Which of these would be
incorrect?
a. 01 data-name pic 99 property.
b. 01 data-name pic 99 property no set.
c. 01 data-name pic 99 property no get. YES
96. If you want to have an implicit set method on an object instance data item, you need to
define the property clause alongside the instance data definition. Which of these would be
incorrect?
a. 01 data-name pic 99 property.
b. 01 data-name pic 99 property no set. YES
c. 01 data-name pic 99 property no get.
97. Which of the following is a class method:
a. YES

b.

98. Which of the following is a class method invocation:


a. Invoke type CircleCalculations.CalculateArea(radius)
returning circle-area
b. Invoke type CircleCalculations::CalculateArea(radius)
returning circle-area YES
c. Invoke CircleCalculations::CalculateArea(radius)
returning circle-area

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

c. 01 Circumference pic 999v9 property. YES

17

You might also like