- 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 will happen if you code GO BACK instead of STOP RUN in a stand alone COBOL program?
A - Program will give run time error.
B - Program will go in infinite loop.
Answer : B
Explanation
A Stop run ends the unit of work and returns control to the operating system whereas GOBACK returns control to calling program. So if we code GO BACK instead of Stop Run, it will go in infinite loop.
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 - Which of the following statement will give you Tutorials in TutorialsPoint string?
Answer : A
Explanation
In STRING(A,B), A is the staring position and B id the number of digits to select.
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. PROCEDURE DIVISION. A-PARA. PERFORM DISPLAY 'A' END-PERFORM. PERFORM C-PARA THRU E-PARA. B-PARA. DISPLAY 'B'. STOP RUN. C-PARA. DISPLAY 'C'. D-PARA. DISPLAY 'D'. E-PARA. DISPLAY 'E'.
Answer : A
Explanation
This is to show how control goes from one Perform statement to other. Go step by step you will understand the flow.
You can try same code using Try it option available below:
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. PROCEDURE DIVISION. A-PARA. PERFORM DISPLAY 'A' END-PERFORM. PERFORM C-PARA THRU E-PARA. B-PARA. DISPLAY 'B'. STOP RUN. C-PARA. DISPLAY 'C'. D-PARA. DISPLAY 'D'. E-PARA. DISPLAY 'E'.
Q 6 - How many times following B-para loop will execute?
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-A PIC 9 VALUE 0. PROCEDURE DIVISION. A-PARA. PERFORM B-PARA VARYING WS-A FROM 1 BY 1 UNTIL WS-A=5 STOP RUN. B-PARA. DISPLAY 'IN B-PARA ' WS-A.
Answer : B
Explanation
B-para will execute for 4 times as value of WS-A is 1 in starting and we are incrementing it by 1 in each iteration. Here condition is WS-A=5 and when this condition will be satisfied it will come out of the loop. So B-para will be executed 4 times.
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 0. PROCEDURE DIVISION. A-PARA. PERFORM B-PARA VARYING WS-A FROM 1 BY 1 UNTIL WS-A=5 STOP RUN. B-PARA. DISPLAY 'IN B-PARA ' WS-A.
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 - Where does Column numbers in COBOL start from?
Answer : A
Explanation
01-07 are reserved for line numbers.
Q 10 - Sign condition is used to check the sign of a numeric operand. It determines whether a given numeric value is greater than, less than, or equal to ZERO. State whether true or false?
Answer : B
Explanation
This statement is correct.
