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 does COBOL stand for?
A - Common Business Oriented Language
B - Common Business Object Language
Answer : A
Explanation
COBOL stands for COmmon Business Oriented Language which was developed to automate the business process.
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 - 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.
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.
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-STRING PIC X(15) VALUE 'ABCDACDADEAAAFF'. PROCEDURE DIVISION. INSPECT WS-STRING REPLACING ALL 'A' BY 'X'. DISPLAY WS-STRING. STOP RUN.
Answer : B
Explanation
Replacing command will replace all the 'A' by 'X'.
You can try same code using Try it option available below:
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-STRING PIC X(15) VALUE 'ABCDACDADEAAAFF'. PROCEDURE DIVISION. INSPECT WS-STRING REPLACING ALL 'A' BY 'X'. DISPLAY WS-STRING. STOP RUN.
Q 7 - Which command is used to place the cursor on a specific record?
Answer : B
Explanation
Start verb can be performed only on indexed and relative files. It is used to place the file pointer at a specific record. The access mode must be sequential or dynamic. File must be opened in I-O or Input mode.
Q 8 - In which usage, data item is similar to Long or Double and is represented as double precision floating point number and internally data is stored in hexadecimal format?
Answer : C
Explanation
COMP-2 is represented as double precision floating point number and internally data is stored in hexadecimal format.
Q 9 - What is the output of following program?
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-STRING PIC A(30). 01 WS-STR1 PIC A(15) VALUE 'Tutorialspoint'. 01 WS-STR2 PIC A(7) VALUE 'Welcome'. 01 WS-STR3 PIC A(7) VALUE 'To AND'. 01 WS-COUNT PIC 99 VALUE 1. PROCEDURE DIVISION. STRING WS-STR2 DELIMITED BY SIZE WS-STR3 DELIMITED BY SPACE WS-STR1 DELIMITED BY SIZE INTO WS-STRING WITH POINTER WS-COUNT ON OVERFLOW DISPLAY 'OVERFLOW!' END-STRING. DISPLAY 'WS-STRING : 'WS-STRING. STOP RUN.
Answer : B
Explanation
String command is used to concatenate the strings.
You can try same code using Try it option available below:
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-STRING PIC A(30). 01 WS-STR1 PIC A(15) VALUE 'Tutorialspoint'. 01 WS-STR2 PIC A(7) VALUE 'Welcome'. 01 WS-STR3 PIC A(7) VALUE 'To AND'. 01 WS-COUNT PIC 99 VALUE 1. PROCEDURE DIVISION. STRING WS-STR2 DELIMITED BY SIZE WS-STR3 DELIMITED BY SPACE WS-STR1 DELIMITED BY SIZE INTO WS-STRING WITH POINTER WS-COUNT ON OVERFLOW DISPLAY 'OVERFLOW!' END-STRING. DISPLAY 'WS-STRING : 'WS-STRING. STOP RUN.
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.