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 - How many times following loop will execute?

MOVE 5 TO X.
PERFORM X TIMES.
MOVE 10 TO X.
END-PERFORM.

A - 11

B - 5

C - 10

D - 15

Answer : B

Explanation

PERFORM loop will execute for 5 times. As it reads the first statement PERFORM 5 times. It replaces X with the value 5.

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

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 X PIC 99.

PROCEDURE DIVISION.
   MOVE 5 TO X.
   PERFORM X TIMES
   MOVE 10 TO X
   DISPLAY 'COUNT'
   END-PERFORM.
   STOP RUN.

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

A - 1-6 Columns

B - 8-11 Columns

C - 12-72 Columns

D - 72-80 Columns

Answer : B

Explanation

Area A starts from 8 to 11 column. All COBOL divisions, sections, paragraphs and some special entries must begin in Area A.

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 - 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 - If the values of variables in the called program are modified, then their new values will not reflect in the calling program. What type of call is this?

A - Call by content

B - Call by reference

C - None of these

Answer : A

Explanation

The new values will not reflect in the calling program when we use call by content.

Q 8 - Which option is used in Inspect verb to replace the string characters?

A - Count

B - Tallying

C - Replacing

D - Add

Answer : C

Explanation

Replacing option is used to replace the string characters.

Q 9 - Where does Identification Area in COBOL starts from?

A - 01 to 07 columns

B - 12 to 72 columns

C - 08 to 11 columns

D - 73 to 80 columns

Answer : D

Explanation

Identification area is used as needed by the programmer.

Q 10 - Decimal point position can be used with numeric data. Assumed position is the position of decimal point and not included in the data. State whether true or false?

A - False

B - True

Answer : B

Explanation

This statement is correct.


cobol_questions_answers.htm

Advertisements