- COBOL - Home
- COBOL - Overview
- COBOL - Environment Setup
- COBOL - Program Structure
- COBOL - Basic Syntax
- COBOL - Data Types
- COBOL - Basic Verbs
- COBOL - Data Layout
- COBOL - Conditional Statements
- COBOL - Loop Statements
- COBOL - String Handling
- COBOL - Table Processing
- COBOL - File Handling
- COBOL - File Organization
- COBOL - File Access Mode
- COBOL - File Handling Verbs
- COBOL - Subroutines
- COBOL - Internal Sort
- COBOL - Database Interface
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.
Q 1 - How is sign stored in a COMP-3 field?
Answer : D
Explanation
In COMP-3 field, sign is stored in last nibble.
Q 2 - How many times following loop will execute?
MOVE 5 TO X. PERFORM X TIMES. MOVE 10 TO X. END-PERFORM.
Answer : B
Explanation
PERFORM loop will execute for 5 times. As it reads the first statement PERFORM 5 times. It replaces X with the value 5.
You can try same code using Try it option available below:
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 X PIC 99. PROCEDURE DIVISION. MOVE 5 TO X. PERFORM X TIMES MOVE 10 TO X DISPLAY 'COUNT' END-PERFORM. STOP RUN.
Q 3 - In which division, Input-Output section?
Answer : B
Explanation
Input-Output section comes under Environment division which provides information about the files to be used in the program.
Answer : C
Explanation
66 level number is used for RENAMES.
Answer : B
Explanation
S9(6) USAGE is COMP-3 will take 3 bytes based on the following formula which is used to calculate when USAGE is COMP-3 :
S9(n) USAGE is COMP-3
Number of bytes = n/2 (If n is even)
Number of bytes = n/2 + 1(If n is odd, consider only integer part)
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.
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 - If the values of variables in the called program are modified, then their new values will not reflect in the calling program. What type of call is this?
Answer : A
Explanation
The new values will not reflect in the calling program when we use call by content.
Q 8 - Which of the following is not a figurative constant?
Answer : B
Explanation
Comma is not a figurative constant. Figurative constants are constant values.
Q 9 - In which division we write logic of the program?
Answer : A
Explanation
Procedure division is used to include the logic of the program. It consists of executable statements using variables defined in the data division. In this division, paragraph and section names are user-defined.
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
