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

Q 1 - How is sign stored in a COMP-3 field?

A - First Bit

B - Last Bit

C - First Nibble

D - Last Nibble

Answer : D

Explanation

In COMP-3 field, sign is stored in last nibble.

Q 2 - Which cobol verb is used for updating a file?

A - READ

B - WRITE

C - UPDATE

D - REWRITE

Answer : D

Explanation

Rewrite verb is used to update the records. File should be opened in I-O mode for rewrite operations. It can be used only after a successful Read operation. Rewrite verb overwrites the last record read.

Answer : B

Explanation

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

Q 4 - Which of the following word cannot be a user-defined COBOL word?

A - WS-ACCEPT

B - ACCEPT

C - WS-DISPLAY

D - TUTORIAL

Answer : B

Explanation

ACCEPT cannot be a user defined COBOL word as we cannot use COBOL reserved words.

Q 5 - How many bytes S9(6) USAGE IS COMP will take?

A - 6

B - 4

C - 3

D - 2

Answer : B

Explanation

S9(6) USAGE is COMP will take 4 bytes based on the following formula which is used to calculate when USAGE is COMP :
S9(n) USAGE is COMP
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.

Q 6 - How many times following B-para loop will execute?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-A PIC 9 VALUE 0.

PROCEDURE DIVISION.
   A-PARA.
   PERFORM B-PARA VARYING WS-A FROM 1 BY 1 UNTIL WS-A=5
   STOP RUN.
   
   B-PARA.
   DISPLAY 'IN B-PARA ' WS-A.

A - 5

B - 4

C - 3

D - 6

Answer : B

Explanation

B-para will execute for 4 times as value of WS-A is 1 in starting and we are incrementing it by 1 in each iteration. Here condition is WS-A=5 and when this condition will be satisfied it will come out of the loop. So B-para will be executed 4 times.

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

PROCEDURE DIVISION.
   A-PARA.
   PERFORM B-PARA VARYING WS-A FROM 1 BY 1 UNTIL WS-A=5
   STOP RUN.
   
   B-PARA.
   DISPLAY 'IN B-PARA ' WS-A.

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 Long or Double and is represented as double precision floating point number and internally data is stored in hexadecimal format?

A - COMP

B - COMP-3

C - COMP-2

D - COMP-1

Answer : C

Explanation

COMP-2 is represented as double precision floating point number and internally data is stored in hexadecimal format.

Q 9 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-STRING PIC A(30) VALUE 'WELCOME TO TUTORIALSPOINT'.
   01 WS-STR1 PIC A(7).
   01 WS-STR2 PIC A(2).
   01 WS-STR3 PIC A(15).
   01 WS-COUNT PIC 99 VALUE 1.

PROCEDURE DIVISION.
   UNSTRING WS-STRING DELIMITED BY SPACE
      INTO WS-STR1, WS-STR2, WS-STR3
   END-UNSTRING.
   
   DISPLAY WS-STR2.
   
STOP RUN.

A - WelcomeTo

B - To

C - Tutorialspoint

D - point

Answer : B

Explanation

Unstring verb is used to split one string into multiple sub-strings.

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 A(30) VALUE 'WELCOME TO TUTORIALSPOINT'.
   01 WS-STR1 PIC A(7).
   01 WS-STR2 PIC A(2).
   01 WS-STR3 PIC A(15).
   01 WS-COUNT PIC 99 VALUE 1.

PROCEDURE DIVISION.
   UNSTRING WS-STRING DELIMITED BY SPACE
      INTO WS-STR1, WS-STR2, WS-STR3
   END-UNSTRING.
   
   DISPLAY WS-STR2.
   
STOP RUN.

Q 10 - What is the length of PIC 999V9?

A - 6

B - 5

C - 3

D - 4

Answer : D

Explanation

It will take 4 bytes, V is Implicit decimal & will not hold any byte.

cobol_questions_answers.htm
Advertisements