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 - What is the length of PIC 9.999?

A - 4

B - 6

C - 5

D - 3

Answer : C

Explanation

Length of PIC 9.999 is 5 as '.' takes 1 byte. So total 1 byte for '.' and 4 bytes for 9.

Q 3 - How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy?

A - 7 bytes

B - 8 bytes

C - 4 bytes

D - 10 bytes

Answer : B

Explanation

9(7) will take 7 bytes and 1 byte for SIGN TRAILING SEPARATE, so total 8 bytes it will take.

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.

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.

A - 06, 10

B - 10, 06

C - Error

D - 100, 15

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 6 - 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 7 - 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 8 - In which usage, data item is similar to Real or Float and is represented as a single precision floating point number and internally data is stored in hexadecimal format?

A - COMP

B - COMP-3

C - COMP-2

D - COMP-1

Answer : D

Explanation

COMP-1 is represented as a single precision floating point number and data is internally stored in hexadecimal format.

Answer : A

Explanation

01-07 are reserved for line numbers.

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