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

Answer : B

Explanation

Identification division contains entries that is used to identify the program. This is the the first division and only mandatory division.

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.

Q 3 - Which of the alphanumeric literal is invalid?

A - 'COBOL12'

B - "COBOL12"

C - "COBOL''12"

D - 'COBOL12"

Answer : D

Explanation

'COBOL12" is invalid because inverted commas should be in pair and should be of same type.

Q 4 - Which level number we should use for conditions?

A - 77

B - 88

C - 01

D - 66

Answer : B

Explanation

88 level number is used for defining condition name entries.

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 PIC A VALUE 'A' OCCURS 5 TIMES.     

PROCEDURE DIVISION.
   DISPLAY WS-TABLE.
STOP RUN.

A - A

B - AAAAA

C - Spaces

D - Error

Answer : B

Explanation

We are displaying the complete table so all the 5 occurrences will come 'AAAAA'.

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 PIC A VALUE 'A' OCCURS 5 TIMES.     

PROCEDURE DIVISION.
   DISPLAY WS-TABLE.
STOP RUN.

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 - 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 - Which division provides information of external data sets used in the program?

A - PROCEDURE DIVISION.

B - IDENTIFICATION DIVISION

C - DATA DIVISION

D - ENVIRONMENT DIVISION

Answer : D

Explanation

In file control paragraph inside Environment division we mention all the information of external data sets used in the program.

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