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 of the following file opening mode is invalid in COBOL?

A - APPEND

B - INPUT

C - OUTPUT

D - EXTEND

Answer : A

Explanation

Valid file opening modes in COBOL are INPUT, OUTPUT, I-O, and EXTEND. APPEND file mode is not available in COBOL.

Q 2 - Can I redefine an X(10) field with a field of X(20)?

A - No

B - Yes

Answer : B

Explanation

Yes we can define a X(10) to X(20) as Redefines causes both fields to start at the same location, but it is not a good coding practice.

Answer : C

Explanation

Linkage section comes under data division which is used in called 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 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-NUM1 PIC 9(9).
   01 WS-NUM2 PIC 9(9).
   
PROCEDURE DIVISION.
   A000-FIRST-PARA.
   MOVE 25 TO WS-NUM1 
   MOVE 15 TO WS-NUM2 
   
   IF WS-NUM1 > WS-NUM2 THEN
      DISPLAY 'IN LOOP 1 - IF BLOCK'
   ELSE
      DISPLAY 'IN LOOP 1 - ELSE BLOCK'
   END-IF.
   
STOP RUN.

A - IN LOOP 1 - ELSE BLOCK

B - IN LOOP 1 - IF BLOCK

C - Error

D - None of these

Answer : B

Explanation

WS-NUM1 is greater than WS-NUM2, so condition is satisfied and it will to IF loop.

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(9).
   
PROCEDURE DIVISION.
   A000-FIRST-PARA.
   MOVE 25 TO WS-NUM1 
   MOVE 15 TO WS-NUM2 
   
   IF WS-NUM1 > WS-NUM2 THEN
      DISPLAY 'IN LOOP 1 - IF BLOCK'
   ELSE
      DISPLAY 'IN LOOP 1 - ELSE BLOCK'
   END-IF.
   
STOP RUN.

Q 6 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-CNT PIC 9(2) VALUE 0.
   01 WS-STRING PIC X(15) VALUE 'AABCDACDAAEAAAF'.
   
PROCEDURE DIVISION.
   INSPECT WS-STRING TALLYING WS-CNT FOR ALL 'A'.
   DISPLAY WS-CNT
   
STOP RUN.

A - 09

B - 06

C - 08

D - 10

Answer : C

Explanation

Inspect statement will count the number of 'A' in the string and will put the value in WS-CNT.

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

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-CNT PIC 9(2) VALUE 0.
   01 WS-STRING PIC X(15) VALUE 'AABCDACDAAEAAAF'.
   
PROCEDURE DIVISION.
   INSPECT WS-STRING TALLYING WS-CNT FOR ALL 'A'.
   DISPLAY WS-CNT
   
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 - In which usage, data item is stored in pack decimal format and each digit occupies half a byte (1 nibble) and the sign is stored at the right most nibble?

A - COMP

B - COMP-3

C - COMP-2

D - COMP-1

Answer : B

Explanation

This statement is self explanatory.

Answer : C

Explanation

In Data Division we declare all the working storage variables.

Q 10 - Elementary items cannot be divided further. Level number, Data name, Picture clause and Value clause (optional) are used to describe an elementary item. State whether true or false?

A - True

B - False

Answer : A

Explanation

This statement is correct.

cobol_questions_answers.htm
Advertisements