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 - What is the mode in which you will OPEN a file for writing?

A - OUTPUT

B - EXTEND

C - Either OUTPUT or EXTEND

D - INPUT-OUTPUT

Answer : C

Explanation

To write into a file, the file has to be opened in either OUTPUT or EXTEND mode.

Q 2 - Which utility is used for compiling COBOL program?

A - IKJEFT01

B - IGYCRCTL

C - IGYCTCRL

D - None of these

Answer : B

Explanation

IGCRCTL utility is used to compile a COBOL program.

Q 3 - Which of the numeric literal is invalid?

A - 100

B - 10.9-

C - -10.9

D - 10.9

Answer : B

Explanation

10.9- is invalid because sign can not be mentioned on the right.

Q 4 - Moving a Numeric field to Alphabetic is legal?

A - Yes

B - No

Answer : B

Explanation

Moving a numeric field to alphabetic field is illegal in COBOL. It will throw error.

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

A - 000000100

B - 000000090

C - 000000070

D - 000000080

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 6 - 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 7 - 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 8 - 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 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 - Decimal point position can be used with numeric data. Assumed position is the position of decimal point and not included in the data. State whether true or false?

A - False

B - True

Answer : B

Explanation

This statement is correct.

cobol_questions_answers.htm
Advertisements