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 maximum size of a numeric field we can define in COBOL?

A - 9(20)

B - 9(18)

C - 9(31)

D - 9(10)

Answer : B

Explanation

COBOL applications use 31 digit numeric fields. However, compiler only supports a maximum of 18 digits. So we use a maximum of 18 digits.

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.

Q 3 - What is the position of Area B in COBOL program?

A - 1-6 Columns

B - 8-11 Columns

C - 12-72 Columns

D - 72-80 Columns

Answer : C

Explanation

Area B start from 12 to 72 column. All COBOL statements must begin in area B.

Q 4 - Which level number we should use for RENAMES clause?

A - 77

B - 49

C - 66

D - 88

Answer : C

Explanation

66 level number is used for RENAMES.

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

Answer : C

Explanation

In Data Division we declare all the working storage variables.

Q 10 - Group items consist of one or more elementary items. Level number, Data name, and Value clause (optional) are used to describe a group item. Group level number is always 01. State whether true or false?

A - False

B - True

Answer : B

Explanation

This statement is true.

cobol_questions_answers.htm
Advertisements