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.

Questions and Answers

COBOL Mock Test III

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

Answer : B

Explanation

This statement is true as with test before is the default condition for Perform until statement.

Q 2 - How many times following B-para loop will execute?

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

Answer : B

Explanation

B-para will execute for 4 times as value of WS-A is 1 in starting and we are incrementing it by 1 in each iteration. Here condition is WS-A=5 and when this condition will be satisfied it will come out of the loop. So B-para will be executed 4 times.

You can try same code using Try it option available below:

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.

Q 3 - What is the output of following program?

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

Answer : B

Explanation

This is to show how control goes from one GOTO statement to other. Go step by step you will understand the flow. From B-para control will go to D-para as value in WS-A is 2, so it will go to the 2nd para which is mentioned in the GOTO statement.

You can try same code using Try it option available below:

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.

Q 4 - What is the output of following program?

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

Answer : C

Explanation

Inspect statement will count the number of 'A' in the string and will put the value in WS-CNT.

You can try same code using Try it option available below:

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.

Q 5 - What is the output of following program?

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

D - Run time error

Answer : B

Explanation

Replacing command will replace all the 'A' by 'X'.

You can try same code using Try it option available below:

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.

Q 6 - What is the output of following program?

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

Answer : B

Explanation

We are displaying the complete table so all the 5 occurrences will come 'AAAAA'.

You can try same code using Try it option available below:

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.

Q 7 - What is the output of following program?

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

Answer : D

Explanation

It is a 2-D array and we are using subscript to the access the elements in the table. WS-C(3,1) has MNO value in it.ws

You can try same code using Try it option available below:

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.

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

Answer : B

Explanation

This statement is true and it is used with Search and Search All to locate elements in table.

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

Answer : B

Explanation

This statement is false as Search is a linear search method where as Search All is binary search method.

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

Answer : A

Explanation

This statement is correct.

Q 11 - How records are stored & accessed in sequential file organization?

A - Relative address method

B - Sequential access method

C - Direct access method

D - Both B & C

Answer : B

Explanation

A sequential file consists of records that are stored and accessed in sequential order.

Q 12 - How records are stored & accessed in indexed file organization?

A - Relative address method

B - Sequential access method

C - Direct access method

D - Both B & C

Answer : D

Explanation

An indexed sequential file consists of records that can be accessed sequentially. Direct access is also possible.

Q 13 - How records are stored & accessed in relative file organization?

A - Relative address

B - Sequentially

C - Directly

D - Both B & C

Answer : A

Explanation

A relative file consists of records ordered by their relative address.

Q 14 - Which command is used to place the cursor on a specific record?

A - Open

B - Start

C - Read next

D - Write

Answer : B

Explanation

Start verb can be performed only on indexed and relative files. It is used to place the file pointer at a specific record. The access mode must be sequential or dynamic. File must be opened in I-O or Input mode.

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

Answer : B

Explanation

This statement is correct.

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

Answer : B

Explanation

This statement is incorrect as the read operation should be successful before doing rewrite operation..

Q 17 - 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 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

Answer : B

Explanation

The new values will reflect in the calling program when we use call by reference.

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

Answer : A

Explanation

The new values will not reflect in the calling program when we use call by content.

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

Answer : B

Explanation

This statement is correct.

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

Answer : B

Explanation

This statement is correct.

Q 22 - Which of the following is not a figurative constant?

A - High-Values

B - Comma

C - Zero

D - Spaces

Answer : B

Explanation

Comma is not a figurative constant. Figurative constants are constant values.

Q 23 - Value clause is an optional clause which is used to initialize the data items. The values can be numeric literal, alphanumeric literal, or figurative constant. State whether true or false?

A - False

B - True

Answer : B

Explanation

This statement is correct.

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

Answer : B

Explanation

This statement is correct.

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

Answer : B

Explanation

This statement is correct.

Answer Sheet

Question Number Answer Key
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
cobol_questions_answers.htm
Advertisements