COBOL Online Quiz


Following quiz provides Multiple Choice Questions (MCQs) related to COBOL Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 1 - Which of the following file opening mode is invalid in COBOL?

A - APPEND

B - INPUT

C - OUTPUT

D - EXTEND

Answer : A

Explanation

Valid file opening modes in COBOL are INPUT, OUTPUT, I-O, and EXTEND. APPEND file mode is not available in COBOL.

Q 2 - Where can we specify OCCURS clause?

A - Elementary Item

B - Group Item

C - Both A & B

D - None of these

Answer : C

Explanation

In array declaration, we can specify occurs clause on Elementary item as well as on Group item also.

Answer : B

Explanation

Search All is a binary search method, which is used to find elements inside the table.

Q 4 - Which level number we should use for conditions?

A - 77

B - 88

C - 01

D - 66

Answer : B

Explanation

88 level number is used for defining condition name entries.

Q 5 - 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'.

A - ACDEB

B - ADCEB

C - DEBAC

D - DACEB

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

Q 6 - 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 7 - 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 8 - 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 9 - In which mode you will open the sequential file to append the data in the end.

A - APPEND

B - INPUT

C - OUTPUT

D - EXTEND

Answer : D

Explanation

Sequential file is opened in Extend mode to append the data at the end. If you will open the file in Output mode it will delete all the existing data and then write the data.

Q 10 - What is the length of PIC S9(7) COMP?

A - 7

B - 6

C - 5

D - 4

Answer : D

Explanation

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

cobol_questions_answers.htm
Advertisements