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

Answer : B

Explanation

FILE-CONTROL paragraph appears in the Input-Ouput Section in the Environment Division which provides information of external data sets used in the program.

Answer : C

Explanation

Linkage section comes under data division which is used in called program.

Q 4 - What is the output of the following code?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-NUM1 PIC 9(9).
   01 WS-NUM2 PIC 9(6).
   
PROCEDURE DIVISION.
   A000-FIRST-PARA.
   MOVE 123456789 TO WS-NUM1.
   MOVE WS-NUM1(3:6) TO WS-NUM2.
   
   DISPLAY WS-NUM2
   
STOP RUN.

A - 456789

B - 000000

C - 123456

D - 345678

Answer : D

Explanation

WS-NUM1(3:6) indicates that select from 3rd column & up to 6 digits. So result will 345678.

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).
   01 WS-NUM2 PIC 9(6).
   
PROCEDURE DIVISION.
   A000-FIRST-PARA.
   MOVE 123456789 TO WS-NUM1.
   MOVE WS-NUM1(3:6) TO WS-NUM2.
   
   DISPLAY WS-NUM2
   
STOP RUN.

Q 5 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-DESCRIPTION.
   05 WS-NUM.
   10 WS-NUM1 PIC 9(2) VALUE 20.
   10 WS-NUM2 PIC 9(2) VALUE 56.
   05 WS-CHAR.
   10 WS-CHAR1 PIC X(2) VALUE 'AA'.
   10 WS-CHAR2 PIC X(2) VALUE 'BB'.
   10 WS-RENAME RENAMES WS-NUM2 THRU WS-CHAR2.

PROCEDURE DIVISION.
   DISPLAY "WS-RENAME : " WS-RENAME.
   
STOP RUN.

A - 56AABB

B - Compilation Error

C - Space

D - Zeroes

Answer : B

Explanation

This program will give compilation error as Renames should be defined at 66 level number.

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

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-DESCRIPTION.
   05 WS-NUM.
   10 WS-NUM1 PIC 9(2) VALUE 20.
   10 WS-NUM2 PIC 9(2) VALUE 56.
   05 WS-CHAR.
   10 WS-CHAR1 PIC X(2) VALUE 'AA'.
   10 WS-CHAR2 PIC X(2) VALUE 'BB'.
   10 WS-RENAME RENAMES WS-NUM2 THRU WS-CHAR2.

PROCEDURE DIVISION.
   DISPLAY "WS-RENAME : " WS-RENAME.
   
STOP RUN.

Q 6 - With test before is the default condition and it indicates that the condition is checked before the execution of statements in a paragraph. Is this statement true or false?

A - False

B - True

Answer : B

Explanation

This statement is true as with test before is the default condition for Perform until statement.

Q 7 - How records are stored & accessed in indexed file organization?

A - Relative address method

B - Sequential access method

C - Direct access method

D - Both B & C

Answer : D

Explanation

An indexed sequential file consists of records that can be accessed sequentially. Direct access is also possible.

Q 8 - Value clause is an optional clause which is used to initialize the data items. The values can be numeric literal, alphanumeric literal, or figurative constant. State whether true or false?

A - False

B - True

Answer : B

Explanation

This statement is correct.

Answer : A

Explanation

Procedure division is used to include the logic of the program. It consists of executable statements using variables defined in the data division. In this division, paragraph and section names are user-defined.

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