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 - Which data type is not available in COBOL?

A - Alphabetic (A)

B - Long (L)

C - Alphanumeric (X)

D - Numeric (9)

Answer : B

Explanation

Long data type is not available in COBOL. COBOL supports three data types Alphabetic, Numeric & Alphanumeric.

Q 2 - If 436 value is moved to a PP999 PIC clause, then what is edited value taken?

A - .00436

B - 00436

C - 436

D - 43600

Answer : A

Explanation

P is assumed decimal scaling position which is used to specify the location of an assumed decimal point when the point is not within the number that appears in the data item. .PIC PP999 means that numeric data item is of 3 characters and there are 5 positions after the decimal point.

Answer : B

Explanation

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

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

A - Yes

B - No

Answer : A

Explanation

Moving a alphabetic field to alphanumeric is legal in COBOL.

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

A - 6

B - 3

C - 4

D - 7

Answer : B

Explanation

S9(6) USAGE is COMP-3 will take 3 bytes based on the following formula which is used to calculate when USAGE is COMP-3 :
S9(n) USAGE is COMP-3
Number of bytes = n/2 (If n is even)
Number of bytes = n/2 + 1(If n is odd, consider only integer part)

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 - How records are stored & accessed in sequential file organization?

A - Relative address method

B - Sequential access method

C - Direct access method

D - Both B & C

Answer : B

Explanation

A sequential file consists of records that are stored and accessed in sequential order.

Q 8 - Which of the following is not a figurative constant?

A - High-Values

B - Comma

C - Zero

D - Spaces

Answer : B

Explanation

Comma is not a figurative constant. Figurative constants are constant values.

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