
- COBOL Tutorial
- COBOL - Home
- COBOL - Overview
- COBOL - Environment Setup
- COBOL - Program Structure
- COBOL - Basic Syntax
- COBOL - Data Types
- COBOL - Basic Verbs
- COBOL - Data Layout
- COBOL - Conditional Statements
- COBOL - Loop Statements
- COBOL - String Handling
- COBOL - Table Processing
- COBOL - File Handling
- COBOL - File Organization
- COBOL - File Access Mode
- COBOL - File Handling Verbs
- COBOL - Subroutines
- COBOL - Internal Sort
- COBOL - Database Interface
- COBOL Useful Resources
- COBOL - Questions and Answers
- COBOL - Quick Guide
- COBOL - Useful Resources
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
COBOL Mock Test
This section presents you various set of Mock Tests related to COBOL Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

COBOL Mock Test II
Q 1 - What is the position of Area B in COBOL program?
Answer : C
Explanation
Area B start from 12 to 72 column. All COBOL statements must begin in area B.
Q 2 - What is the position of Area A in COBOL program?
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.
Q 3 -How you will comment a line in a COBOL program?
A - Code asterisk(*) at 1st column.
B - Code asterisk(*) at 7th column.
Answer : B
Explanation
Coding asterisk (*) at 7th column comments out the complete line in COBOL program.
Q 4 - Which of the alphanumeric literal is invalid?
Answer : D
Explanation
'COBOL12" is invalid because inverted commas should be in pair and should be of same type.
Answer : B
Explanation
10.9- is invalid because sign can not be mentioned on the right.
Q 6 - Which of the following word cannot be a user-defined COBOL word?
Answer : B
Explanation
ACCEPT cannot be a user defined COBOL word as we cannot use COBOL reserved words.
Answer : C
Explanation
66 level number is used for RENAMES.
Answer : B
Explanation
88 level number is used for defining condition name entries.
Q 9 - What is the output of following program?
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NUM1 PIC X(4) VALUE '15AB'. PROCEDURE DIVISION. MOVE 'XXXX' TO WS-NUM1 DISPLAY WS-NUM1. STOP RUN.
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.
Q 10 - What is the output of following program?
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-ID PIC 9(5). PROCEDURE DIVISION. A000-FIRST-PARA. INITIALIZE WS-ID REPLACING NUMERIC DATA BY 12345. DISPLAY WS-ID. STOP RUN.
Answer : B
Explanation
WS-ID will be initialized and numeric data will be replaced by 12345 as mentioned in the statement.
You can try same code using Try it option available below:
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.
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.
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.
Answer : B
Explanation
Moving a numeric field to alphabetic field is illegal in COBOL. It will throw error.
Answer : B
Explanation
Moving a alphabetic field to numeric field is illegal in COBOL. It will throw error.
Answer : A
Explanation
Moving a numeric field to alphanumeric is legal in COBOL.
Answer : A
Explanation
Moving a alphabetic field to alphanumeric is legal in COBOL.
Q 16 - What is the output of following program?
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NUMA PIC 9(9) VALUE 10. 01 WS-NUMB PIC 9(9) VALUE 10. 01 WS-NUMC PIC 9(9) VALUE 10. 01 WS-NUMD PIC 9(9) VALUE 100. 01 WS-NUME PIC 9(9) VALUE 10. PROCEDURE DIVISION. SUBTRACT WS-NUMA WS-NUMB WS-NUMC FROM WS-NUMD GIVING WS-NUME. DISPLAY WS-NUME. STOP RUN.
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.
Q 17 - What is the output of following program?
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NUMA PIC 9(9) VALUE 100. 01 WS-NUMB PIC 9(9) VALUE 15. 01 WS-NUMC PIC 9(2). 01 WS-REM PIC 9(2). PROCEDURE DIVISION. DIVIDE WS-NUMA BY WS-NUMB GIVING WS-NUMC REMAINDER WS-REM. DISPLAY WS-NUMC ', ' WS-REM STOP RUN.
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 18 - What is the output of following program?
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NUM1 PIC 9(9) VALUE 10 . 01 WS-NUM2 PIC 9(9) VALUE 10. 01 WS-NUM3 PIC 9(9) VALUE 10. 01 WS-NUMA PIC 9(9) VALUE 50. 01 WS-NUMB PIC 9(9) VALUE 10. 01 WS-NUMC PIC 9(3). PROCEDURE DIVISION. COMPUTE WS-NUMC= (WS-NUM1 * WS-NUM2) - (WS-NUMA / WS-NUMB) + WS-NUM3. DISPLAY WS-NUMC STOP RUN.
Answer : B
Explanation
This is simple example to show the use of Compute statement.
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) 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.
Q 19 - What is the output of following program?
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-DESCRIPTION. 05 WS-DATE1 VALUE '20140831'. 10 WS-YEAR PIC X(4). 10 WS-MONTH PIC X(2). 10 WS-DATE PIC X(2). 05 WS-DATE2 REDEFINES WS-DATE1 PIC 9(8). PROCEDURE DIVISION. DISPLAY WS-DATE2. STOP RUN.
Answer : B
Explanation
When we redefine WS-DATE1 to WS-DATE2, automatically values from WS-DATE1 will be moved to WS-DATE2.
You can try same code using Try it option available below:
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.
Q 20 - What is the output of following program?
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-DESCRIPTION. 05 WS-NUM. 10 WS-NUM1 PIC 9(2) VALUE 20. 10 WS-NUM2 PIC 9(2) VALUE 56. 05 WS-CHAR. 10 WS-CHAR1 PIC X(2) VALUE 'AA'. 10 WS-CHAR2 PIC X(2) VALUE 'BB'. 10 WS-RENAME RENAMES WS-NUM2 THRU WS-CHAR2. PROCEDURE DIVISION. DISPLAY "WS-RENAME : " WS-RENAME. STOP RUN.
Answer : B
Explanation
This program will give compilation error as Renames should be defined at 66 level number.
You can try same code using Try it option available below:
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.
Answer : B
Explanation
S9(6) USAGE is COMP will take 4 bytes based on the following formula which is used to calculate when USAGE is COMP :
S9(n) USAGE is COMP
If 'n' = 1 to 4, it takes 2 bytes.
If 'n' = 5 to 9, it takes 4 bytes.
If 'n' = 10 to 18, it takes 8 bytes.
Answer : B
Explanation
S9(6) USAGE is COMP-3 will take 3 bytes based on the following formula which is used to calculate when USAGE is COMP-3 :
S9(n) USAGE is COMP-3
Number of bytes = n/2 (If n is even)
Number of bytes = n/2 + 1(If n is odd, consider only integer part)
Q 23 - What is the output of following program?
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NUM1 PIC 9(9). 01 WS-NUM2 PIC 9(9). PROCEDURE DIVISION. A000-FIRST-PARA. MOVE 25 TO WS-NUM1 MOVE 15 TO WS-NUM2 IF WS-NUM1 > WS-NUM2 THEN DISPLAY 'IN LOOP 1 - IF BLOCK' ELSE DISPLAY 'IN LOOP 1 - ELSE BLOCK' END-IF. STOP RUN.
Answer : B
Explanation
WS-NUM1 is greater than WS-NUM2, so condition is satisfied and it will to IF loop.
You can try same code using Try it option available below:
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NUM1 PIC 9(9). 01 WS-NUM2 PIC 9(9). PROCEDURE DIVISION. A000-FIRST-PARA. MOVE 25 TO WS-NUM1 MOVE 15 TO WS-NUM2 IF WS-NUM1 > WS-NUM2 THEN DISPLAY 'IN LOOP 1 - IF BLOCK' ELSE DISPLAY 'IN LOOP 1 - ELSE BLOCK' END-IF. STOP RUN.
Q 24 - What is the output of following program?
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NUM PIC 9(3). 88 PASS VALUES ARE 041 THRU 100. 88 FAIL VALUES ARE 000 THRU 40. PROCEDURE DIVISION. A000-FIRST-PARA. MOVE 65 TO WS-NUM. IF PASS DISPLAY 'Passed with ' WS-NUM ' marks'. IF FAIL DISPLAY 'FAILED with ' WS-NUM 'marks'. STOP RUN.
Answer : B
Explanation
WS-NUM contains 65 so PASS condition is satisfied as values lies in range of 041 to 100.
You can try same code using Try it option available below:
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.
Q 25 - What is the output of following program?
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. PROCEDURE DIVISION. A-PARA. PERFORM DISPLAY 'A' END-PERFORM. PERFORM C-PARA THRU E-PARA. B-PARA. DISPLAY 'B'. STOP RUN. C-PARA. DISPLAY 'C'. D-PARA. DISPLAY 'D'. E-PARA. DISPLAY 'E'.
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'.
Answer Sheet
Question Number | Answer Key |
---|---|
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 |