- 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 - What is the maximum size of a numeric field we can define in COBOL?
Answer : B
Explanation
COBOL applications use 31 digit numeric fields. However, compiler only supports a maximum of 18 digits. So we use a maximum of 18 digits.
Answer : C
Explanation
Length of PIC 9.999 is 5 as '.' takes 1 byte. So total 1 byte for '.' and 4 bytes for 9.
Q 3 - How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy?
Answer : B
Explanation
9(7) will take 7 bytes and 1 byte for SIGN TRAILING SEPARATE, so total 8 bytes it will take.
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-NUMA PIC 9(9) VALUE 100. 01 WS-NUMB PIC 9(9) VALUE 15. 01 WS-NUMC PIC 9(2). 01 WS-REM PIC 9(2). PROCEDURE DIVISION. DIVIDE WS-NUMA BY WS-NUMB GIVING WS-NUMC REMAINDER WS-REM. DISPLAY WS-NUMC ', ' WS-REM STOP RUN.
Answer : A
Explanation
Formula will be like WS-NUMC = NUMA/NUMB and remainder will be stored in WS-REM.
You can try same code using Try it option available below:
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NUMA PIC 9(9) VALUE 100. 01 WS-NUMB PIC 9(9) VALUE 15. 01 WS-NUMC PIC 9(2). 01 WS-REM PIC 9(2). PROCEDURE DIVISION. DIVIDE WS-NUMA BY WS-NUMB GIVING WS-NUMC REMAINDER WS-REM. DISPLAY WS-NUMC ', ' WS-REM 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 OCCURS 3 TIMES.
10 WS-B PIC A(2).
10 WS-C OCCURS 2 TIMES.
15 WS-D PIC X(3).
PROCEDURE DIVISION.
MOVE '12ABCDEF34GHIJKL56MNOPQR' TO WS-TABLE.
DISPLAY 'WS-C(3,1) : ' WS-C(3,1).
STOP RUN.
Answer : D
Explanation
It is a 2-D array and we are using subscript to the access the elements in the table. WS-C(3,1) has MNO value in it.ws
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 OCCURS 3 TIMES.
10 WS-B PIC A(2).
10 WS-C OCCURS 2 TIMES.
15 WS-D PIC X(3).
PROCEDURE DIVISION.
MOVE '12ABCDEF34GHIJKL56MNOPQR' TO WS-TABLE.
DISPLAY 'WS-C(3,1) : ' WS-C(3,1).
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?
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?
Answer : D
Explanation
COMP-1 is represented as a single precision floating point number and data is internally stored in hexadecimal format.
Q 9 - Where does Column numbers in COBOL start from?
Answer : A
Explanation
01-07 are reserved for line numbers.
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
