- COBOL Tutorial
- 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 Useful Resources
- COBOL - Questions and Answers
- COBOL - Quick Guide
- COBOL - Useful Resources
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.
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 - What is the position of Area A in COBOL program?
Answer : B
Explanation
Area A starts from 8 to 11 column. All COBOL divisions, sections, paragraphs and some special entries must begin in Area A.
Q 4 - What is the output of following program?
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-NUM1 PIC X(4) VALUE '15AB'. PROCEDURE DIVISION. MOVE 'XXXX' TO WS-NUM1 DISPLAY WS-NUM1. STOP RUN.
Answer : B
Explanation
Value of WS-NUM1 will be displayed. While declaring the WS-NUM1 variable we have set the value as '15AB' but in the procedure division we have moved 'XXXX' value in WS-NUM1. So XXXX value is displayed.
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 X(4) VALUE '15AB'. PROCEDURE DIVISION. MOVE 'XXXX' TO WS-NUM1 DISPLAY WS-NUM1. 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) VALUE 10 . 01 WS-NUM2 PIC 9(9) VALUE 10. 01 WS-NUM3 PIC 9(9) VALUE 10. 01 WS-NUMA PIC 9(9) VALUE 50. 01 WS-NUMB PIC 9(9) VALUE 10. 01 WS-NUMC PIC 9(3). PROCEDURE DIVISION. COMPUTE WS-NUMC= (WS-NUM1 * WS-NUM2) - (WS-NUMA / WS-NUMB) + WS-NUM3. DISPLAY WS-NUMC STOP RUN.
Answer : B
Explanation
This is simple example to show the use of Compute statement.
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) VALUE 10 . 01 WS-NUM2 PIC 9(9) VALUE 10. 01 WS-NUM3 PIC 9(9) VALUE 10. 01 WS-NUMA PIC 9(9) VALUE 50. 01 WS-NUMB PIC 9(9) VALUE 10. 01 WS-NUMC PIC 9(3). PROCEDURE DIVISION. COMPUTE WS-NUMC= (WS-NUM1 * WS-NUM2) - (WS-NUMA / WS-NUMB) + WS-NUM3. DISPLAY WS-NUMC STOP RUN.
Q 6 - What is the output of following program?
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-CNT PIC 9(2) VALUE 0. 01 WS-STRING PIC X(15) VALUE 'AABCDACDAAEAAAF'. PROCEDURE DIVISION. INSPECT WS-STRING TALLYING WS-CNT FOR ALL 'A'. DISPLAY WS-CNT STOP RUN.
Answer : C
Explanation
Inspect statement will count the number of 'A' in the string and will put the value in WS-CNT.
You can try same code using Try it option available below:
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-CNT PIC 9(2) VALUE 0. 01 WS-STRING PIC X(15) VALUE 'AABCDACDAAEAAAF'. PROCEDURE DIVISION. INSPECT WS-STRING TALLYING WS-CNT FOR ALL 'A'. DISPLAY WS-CNT STOP RUN.
Q 7 - How records are stored & accessed in sequential file organization?
Answer : B
Explanation
A sequential file consists of records that are stored and accessed in sequential order.
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 - In which mode you will open the sequential file to append the data in the end.
Answer : D
Explanation
Sequential file is opened in Extend mode to append the data at the end. If you will open the file in Output mode it will delete all the existing data and then write the data.
Answer : D
Explanation
COMP-2 takes 8 bytes of storage.
To Continue Learning Please Login
Login with Google