You are on page 1of 16

COBOL Exam Questions

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

a. Nothing, because the code has a syntax error


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
6. Which of the following is an invalid paragraph name?
a. A-1
b. 999X
c. A+1
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
8. Where does AREA A in COBOL extends from?
a. 8-16
b. 8-11
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 Questions

a. 3
b. 4
c. 5
d. 6
10. Where does AREA B in COBOL extend from?
a. 8-11
b. 8-16
c. 12-72
11. The FILE-CONTROL paragraph in a COBOL program appears in
a. Input-Output Section in Environment Division
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
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
b. OPEN I-O
c. OPEN EXTEND
d. OPEN OUTPUT
14. ROUNDED precedes the ON SIZE ERROR?
a. TRUE
b. FALSE
15. A Numeric data item in COBOL can have at most how many digits?
a. 10
b. 160
c. 18
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
17. A 01 level cannot have PIC clause?
a. TRUE
b. FALSE
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 Questions

d. OPEN INDEXED
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
d. It must be opened in EXTEND mode
20. Which of the following is not a PROCEDURE DIVISION verb
a. START
b. SEEK
c. RERUN
d. DELETE
e. REWRITE
f. INSERT
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
d. DELETE
22. In case of a data file, the ACCESS MODE clause must always be specified.
a. TRUE
b. FALSE
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
c. The word FILLER can be replaced with spaces.
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
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
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
27. The name of a program is contained in:
a. Data Division
b. Procedure Division
c. Identification Division
d. Environment Division

4
COBOL Exam Questions

28. In an indexed file, the START statement enables the programmers to start processing from
any record position.
a. TRUE
b. FALSE
29. The UNSTRING verb is used to transfer data from several sources to one receiving field.
a. TRUE
b. FALSE
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
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
32. The INSPECT statement can be used to check whether the value in a data name is numeric
a. TRUE
b. FALSE
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.
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
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
c. 13
d. 14
36. How do you define a variable of COMP-3?
a. 01 WS-VAR PIC S9(4) COMP-3.
b. 01 WS-VAR USAGE COMP-3.
c. 01 WS-VAR COMP-3.
d. 01 WS-VAR COMP-3 USAGE.

5
COBOL Exam Questions

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
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
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
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
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
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
c. SUBTRACT A FROM D, B FROM E, C FROM F
d. SUBTRACT A FROM B GIVING D E F.
43. What is the linkage section?
a. It is must for called program
b. It is must for calling program

6
COBOL Exam Questions

c. Used for displaying messages in sub program


d. Temporary storage for called program

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.
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
46. After the above move, is WS-NEW greater than or less than WS-OLD
a. WS-NEW is greater than WS-OLD
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
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
c. 21.6

7
COBOL Exam Questions

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
50. 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
c. PROG, PARA-2, PARA-3
51. 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
52. Assuming you have a sequential file defined by the following Select statement:
SELECT INFILE ASSIGN INNAME
Which of the following clauses is valid:
a. FILE STATUS IS FILE STATUS.
b. FILE-STATUS IS FILE-STATUS.
c. FILE STATUS IS FILE-STATUS.
d. FILE-STATUS IS FILE STATUS.
e. None of the above.

8
COBOL Exam Questions

53. In data division which of the following sections allow you to put VALUE clauses
a. WORKING-STORAGE SECTION.
b. FILE SECTION.
c. LINKAGE SECTION.
54. 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.
b. The receiving pic x(10) field will contain the last 10 characters from the sending
pic x(20) field.
55. 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.
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.
56. The figurative constants ZERO, ZEROS, ZEROES all mean the same thing?
a. TRUE
b. FALSE
57. The use of single quotes ' and double quotes " in the definition of a literal have exactly the
same meaning?
a. TRUE
b. FALSE
58. 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
c. The program waits for a user to press the Enter key and then terminates.
59. You can define the same data name more than once in a program.
a. TRUE
b. FALSE
60. 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
61. 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
b. FALSE
62. 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.

9
COBOL Exam Questions

c. else
d. perform invalid-record
e. end-if
63. 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
64. 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
b. FALSE
65. 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.
f. None of the above a. thru d.
66. 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
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 FS-DATA FROM WS-DATA
a. TRUE
b. FALSE
68. Under an FD statement the file record definition cannot contain value clauses but it can
contain level 88 condition names:
a. TRUE
b. FALSE
69. The following 88 syntax is valid?
88 VALID-DATA PIC 9(4) VALUE 20 THRU 2000.
a. TRUE

10
COBOL Exam Questions

b. FALSE
70. 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.
c. Both a. and b.
d. Neither a. not b.
71. 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
d. 1,4,5,1,2,3
72. 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.

a. TRUE
b. FALSE
73. This program causes an infinite loop?
PROCEDURE DIVISION.
PROG.
PERFORM PARA-2
STOP RUN.
PARA-1.
DISPLAY "1"

11
COBOL Exam Questions
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
74. 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
b. No Problem
75. 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
b. No Problem
76. 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
b. First and second line
c. Third line
d. All 3 lines
e. None of them.

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

12
COBOL Exam Questions

a. TRUE
b. FALSE
78. 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
b. Invalid
79. Is the following IF syntax valid
IF A = B
PERFORM PROC-1
ELSE
PERFORM PROC-2.
END-IF
a. Valid
b. Invalid
80. 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
d. The code does not compile
81. 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
DISPLAY ‘KEY OK’
END-START
a. VALID
b. INVALID
82. 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

13
COBOL Exam Questions

83. 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
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 ‘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
b. INVALID
85. 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
b. INVALID
86. 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
b. –$2,345.67
c. $ 2,345.67
d. -2,345.67$

Section 2 – Object COBOL


87. What is the name of the .NET intermediate language?
a. .NET IL
b. MSIL
c. RTS
d. CLR
e. JCM
88. The following code syntax is valid:
Method-ID Calculate.
Procedure Division.
Compute CircleArea = 3.14 * Radius * Radius
Compute Circumference = 6.28 * Radius
.

14
COBOL Exam Questions
End Class.
End Method.
a. TRUE
b. FALSE
89. 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
d. Neither
90. The declaration of a CircleObject is:
circleObject type CircleCalculations.
a. TRUE
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
91. Invalid

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


a. 01 circleObject is CircleCalculations.
b. 01 circleObject type CircleCalculations.
c. 01 circleObject pic 999 type CircleCalculations.
d. 01 circleObject pic X(20) type CircleCalculations.
92. 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()
c. Invoke type CircleCalculations::New() Returning circleObject
d. Move CircleCalculations::New()to circleObject
93. A client to a Web Service can be:
a. A Web Form
b. A Win Form
c. A Console Application
d. Any of these
e. None of these

15
COBOL Exam Questions

94. 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.
95. 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.
c. 01 data-name pic 99 property no get.
96. Which of the following is a class method:
a.

b.

97. 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
c. Invoke CircleCalculations::CalculateArea(radius)
returning circle-area

98. 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.
c. 01 Circumference pic 999v9 property.
99. 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

16

You might also like