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

Answer : B

Explanation

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

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.

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

A - 1-6 Columns

B - 8-11 Columns

C - 12-72 Columns

D - 72-80 Columns

Answer : C

Explanation

Area B start from 12 to 72 column. All COBOL statements must begin in area B.

Q 4 - Moving a Numeric field to Alphanumeric is legal?

A - Yes

B - No

Answer : A

Explanation

Moving a numeric field to alphanumeric is legal in COBOL.

Q 5 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-NUM PIC 9(3).
   88 PASS VALUES ARE 041 THRU 100.
   88 FAIL VALUES ARE 000 THRU 40.

PROCEDURE DIVISION.
   A000-FIRST-PARA.
   MOVE 65 TO WS-NUM.
   
   IF PASS 
      DISPLAY 'Passed with ' WS-NUM ' marks'.
      
   IF FAIL 
      DISPLAY 'FAILED with ' WS-NUM 'marks'.
      
STOP RUN.

A - Compilation error

B - Passed with 065 marks

C - FAILED with 065 marks

D - None of these

Answer : B

Explanation

WS-NUM contains 65 so PASS condition is satisfied as values lies in range of 041 to 100.

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

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-NUM PIC 9(3).
   88 PASS VALUES ARE 041 THRU 100.
   88 FAIL VALUES ARE 000 THRU 40.

PROCEDURE DIVISION.
   A000-FIRST-PARA.
   MOVE 65 TO WS-NUM.
   
   IF PASS 
      DISPLAY 'Passed with ' WS-NUM ' marks'.
      
   IF FAIL 
      DISPLAY 'FAILED with ' WS-NUM 'marks'.
      
STOP RUN.

Q 6 - Search is a binary search method, which is used to find elements inside the table. Is this statement true or false?

A - True

B - False

Answer : B

Explanation

This statement is false as Search is a linear search method where as Search All is binary search method.

Q 7 - Rewrite verb is used to update the records. File should be opened in I-O mode for rewrite operations. It can be used even if read operation is not successful. Is this statement true or false?

A - True

B - False

Answer : B

Explanation

This statement is incorrect as the read operation should be successful before doing rewrite operation..

Q 8 - Dynamic Call occurs when a program is compiled with the DYNAM and NODLL compiler option. A dynamic called program is loaded into storage at runtime. Is this statement true or false?

A - False

B - True

Answer : B

Explanation

This statement is correct.

Q 9 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-STRING PIC A(30) VALUE 'WELCOME TO TUTORIALSPOINT'.
   01 WS-STR1 PIC A(7).
   01 WS-STR2 PIC A(2).
   01 WS-STR3 PIC A(15).
   01 WS-COUNT PIC 99 VALUE 1.

PROCEDURE DIVISION.
   UNSTRING WS-STRING DELIMITED BY SPACE
      INTO WS-STR1, WS-STR2, WS-STR3
   END-UNSTRING.
   
   DISPLAY WS-STR2.
   
STOP RUN.

A - WelcomeTo

B - To

C - Tutorialspoint

D - point

Answer : B

Explanation

Unstring verb is used to split one string into multiple sub-strings.

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

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-STRING PIC A(30) VALUE 'WELCOME TO TUTORIALSPOINT'.
   01 WS-STR1 PIC A(7).
   01 WS-STR2 PIC A(2).
   01 WS-STR3 PIC A(15).
   01 WS-COUNT PIC 99 VALUE 1.

PROCEDURE DIVISION.
   UNSTRING WS-STRING DELIMITED BY SPACE
      INTO WS-STR1, WS-STR2, WS-STR3
   END-UNSTRING.
   
   DISPLAY WS-STR2.
   
STOP RUN.

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