COBOL Online Quiz


Advertisements

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

Answer : A

Explanation

COBOL stands for COmmon Business Oriented Language which was developed to automate the business process.

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.

Answer : B

Explanation

Input-Output section comes under Environment division which provides information about the files to be used in the program.

Q 4 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-NUM1 PIC X(4) VALUE '15AB'.
   
PROCEDURE DIVISION.
   MOVE 'XXXX' TO WS-NUM1
   DISPLAY WS-NUM1.
STOP RUN.

A - 15AB

B - XXXX

C - Compilation error

D - Run time error

Answer : B

Explanation

Value of WS-NUM1 will be displayed. While declaring the WS-NUM1 variable we have set the value as '15AB' but in the procedure division we have moved 'XXXX' value in WS-NUM1. So XXXX value is displayed.

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

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-NUM1 PIC X(4) VALUE '15AB'.
   
PROCEDURE DIVISION.
   MOVE 'XXXX' TO WS-NUM1
   DISPLAY WS-NUM1.
STOP RUN.

Q 5 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-NUM1 PIC 9(9) VALUE 10 .
   01 WS-NUM2 PIC 9(9) VALUE 10.
   01 WS-NUM3 PIC 9(9) VALUE 10.
   01 WS-NUMA PIC 9(9) VALUE 50.
   01 WS-NUMB PIC 9(9) VALUE 10.
   01 WS-NUMC PIC 9(3).

PROCEDURE DIVISION.
   COMPUTE WS-NUMC= (WS-NUM1 * WS-NUM2) - (WS-NUMA / WS-NUMB) + WS-NUM3.
   DISPLAY WS-NUMC

STOP RUN.

A - 100

B - 105

C - Compilation error

D - Run time error

Answer : B

Explanation

This is simple example to show the use of Compute statement.

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

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-NUM1 PIC 9(9) VALUE 10 .
   01 WS-NUM2 PIC 9(9) VALUE 10.
   01 WS-NUM3 PIC 9(9) VALUE 10.
   01 WS-NUMA PIC 9(9) VALUE 50.
   01 WS-NUMB PIC 9(9) VALUE 10.
   01 WS-NUMC PIC 9(3).

PROCEDURE DIVISION.
   COMPUTE WS-NUMC= (WS-NUM1 * WS-NUM2) - (WS-NUMA / WS-NUMB) + WS-NUM3.
   DISPLAY WS-NUMC

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 - 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 - 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 : C

Explanation

In Data Division we declare all the working storage variables.

Q 10 - What is the length of a variable when usage is COMP-2?

A - 2

B - 16

C - 4

D - 8

Answer : D

Explanation

COMP-2 takes 8 bytes of storage.

cobol_questions_answers.htm
Advertisements