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 - What is the mode in which you will OPEN a file for writing?

A - OUTPUT

B - EXTEND

C - Either OUTPUT or EXTEND

D - INPUT-OUTPUT

Answer : C

Explanation

To write into a file, the file has to be opened in either OUTPUT or EXTEND mode.

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.

Q 3 - Which of the following statement will give you ‘Tutorials’ in TutorialsPoint string?

A - TutorialsPoint(1:9)

B - TutorialsPoint(9)

C - TutorialsPoint(9:1)

D - TutorialsPoint(9:9)

Answer : A

Explanation

In STRING(A,B), A is the staring position and B id the number of digits to select.

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).
   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-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 - For deleting a record, in which mode we should open the file?

A - Input-Output

B - Input

C - Output

D - Extend

Answer : A

Explanation

Delete verb can be performed only on indexed and relative files. The file must be opened in I-O mode. In sequential file organization, records cannot be deleted. The record last read by the Read statement is deleted in case of sequential access mode. In random access mode, specify the record key and then perform the Delete operation.

Q 8 - In which usage, data item is similar to Real or Float and is represented as a single precision floating point number and internally data is stored in hexadecimal format?

A - COMP

B - COMP-3

C - COMP-2

D - COMP-1

Answer : D

Explanation

COMP-1 is represented as a single precision floating point number and data is internally stored in hexadecimal format.

Q 9 - Which statement we should not use in called program?

A - Linkage Section

B - Procedure Division Using

C - Stop Run

D - Exit Program

Answer : C

Explanation

We should not use Stop Run in called program as the calling program is expecting the control back. Stop run will end the execution and will return the control back to operating system.

Q 10 - Sign condition is used to check the sign of a numeric operand. It determines whether a given numeric value is greater than, less than, or equal to ZERO. State whether true or false?

A - False

B - True

Answer : B

Explanation

This statement is correct.

cobol_questions_answers.htm
Advertisements