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 : A

Explanation

COBOL stands for COmmon Business Oriented Language which was developed to automate the business process.

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.

Answer : B

Explanation

Search All is a binary search method, which is used to find elements inside the table.

Q 4 - What is the output of following program?

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-ID PIC 9(5).
   
PROCEDURE DIVISION.
   A000-FIRST-PARA.
   INITIALIZE WS-ID REPLACING NUMERIC DATA BY 12345.
   DISPLAY WS-ID.
   
STOP RUN.

A - 00000

B - 12345

C - Spaces

D - Compilation error

Answer : B

Explanation

WS-ID will be initialized and numeric data will be replaced by 12345 as mentioned in the statement.

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

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 WS-ID PIC 9(5).
   
PROCEDURE DIVISION.
   A000-FIRST-PARA.
   INITIALIZE WS-ID REPLACING NUMERIC DATA BY 12345.
   DISPLAY WS-ID.
   
STOP RUN.

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-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 - Write verb is used to insert records in a file. Once the record is written, it is no longer available in the record buffer. Is this statement true or false?

A - False

B - True

Answer : B

Explanation

This statement is correct.

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 - What is the length of PIC S9(7) COMP?

A - 7

B - 6

C - 5

D - 4

Answer : D

Explanation

If 'n' = 1 to 4, it takes 2 bytes.
If 'n' = 5 to 9, it takes 4 bytes.
If 'n' = 10 to 18, it takes 8 bytes


cobol_questions_answers.htm

Advertisements