1.
What is the output of the code below?
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-STRING PIC A(30) VALUE 'WELCOME TO COBOL WORLD'.
01 WS-STR1 PIC A(7).
01 WS-STR2 PIC A(2).
01 WS-STR3 PIC A(15).
01 WS-COUNT PIC 99 VALUE 1.
PROCEDURE DIVISION.
UNSTRING WS-STRING DELIMITED BY SPACE
INTO WS-STR1, WS-STR2, WS-STR3
END-UNSTRING.
DISPLAY WS-STR2.
STOP RUN.
Correct Answer
B. TO
Explanation
The code uses the UNSTRING statement to break down the value of WS-STRING into three separate strings, WS-STR1, WS-STR2, and WS-STR3, using a space as the delimiter. The value "TO" is assigned to WS-STR2. The DISPLAY statement then outputs the value of WS-STR2, which is "TO".
2.
What is the output of the 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.
Correct Answer
D. MNO
Explanation
The program declares a table called WS-TABLE with three occurrences of WS-A. Each occurrence of WS-A has a field WS-B and an array WS-C with two occurrences. Each occurrence of WS-C has a field WS-D. The program then moves the string '12ABCDEF34GHIJKL56MNOPQR' to WS-TABLE. The DISPLAY statement displays the value of WS-C(3,1), which is the first occurrence of WS-C in the third occurrence of WS-A. Therefore, the output would be 'MNO'.
3.
How many times following loop will execute?
MOVE 5 TO X.
PERFORM X TIMES
MOVE 10 TO X
END-PERFORM.
Correct Answer
B. 5
Explanation
The loop will execute 5 times because the initial value of X is 5. In each iteration of the loop, the value of X is set to 10. Therefore, the loop will execute 5 times, resulting in the final value of X being 15.
4.
If after an arithmetic operation, the result exceeds the largest value that can be accommodated in the result field, the error is called a ________.
Correct Answer
SIZE ERROR
Explanation
If the result of an arithmetic operation is larger than the maximum value that can be stored in the result field, it is considered a SIZE ERROR. This error occurs when the result exceeds the capacity of the variable or field used to store it, causing an overflow. The SIZE ERROR indicates that the result cannot be accommodated within the given space, and it is necessary to handle this error to prevent data corruption or loss.
5.
The ________ clause eliminates the need for separate entries for the repeated data items.
A. REDEFINES
B. RENAME
C. USAGE
D. OCCURS
Correct Answer
OCCURS, D, D. OCCURS
Explanation
The OCCURS clause eliminates the need for separate entries for the repeated data items. By specifying the number of times a data item should occur, it allows for efficient storage and retrieval of data without the need for redundant entries. In this case, the answer indicates that the OCCURS clause is the correct choice, and it appears twice in the answer.
6.
If initially A=30 and B=60 then execute the statement bellow
MOVE A B TO C.
What is the resultant of C?
Correct Answer
D. Syntax error
Explanation
The statement "MOVE A B TO C" is not a valid syntax in most programming languages. The correct syntax would be "MOVE A TO C" or "MOVE B TO C". Therefore, the given statement contains a syntax error.
7.
PERFORM P2
VARYING I FROM 1 BY 1 UNTIL I <10
END-PERFORM.
How many times P2 will be executed?
Correct Answer
C. 0
Explanation
The PERFORM statement is used to create a loop in COBOL. In this case, P2 will be executed until the condition I < 10 is no longer true. However, since the initial value of I is 1 and it is incremented by 1 each time, the condition will never be true and the loop will not be executed at all. Therefore, the correct answer is 0.
8.
MOVE 123456789 TO WS-NUM1.
MOVE WS-NUM1(3:6) TO WS-NUM2.
DISPLAY WS-NUM2
What is the output of the DISPLAY?
Correct Answer
A. 345678
Explanation
The output of the DISPLAY statement will be 345678. This is because the MOVE statement moves the value of WS-NUM1(3:6), which is 345678, to WS-NUM2. Therefore, when WS-NUM2 is displayed, it will show 345678.
9.
After the execution of one of the when clauses, the control is automatically passed on to the next sentence after the EVALUATE statement. There is no need for any extra code.
Correct Answer
A. True
Explanation
After the execution of one of the when clauses, the control is automatically passed on to the next sentence after the EVALUATE statement. This means that there is no need for any extra code to transfer control to the next sentence. Therefore, the statement "After the execution of one of the when clauses, the control is automatically passed on to the next sentence after the EVALUATE statement" is true.
10.
LINKAGE-SECTION present which DIVISION?
Correct Answer
C. DATA DIVISION
Explanation
The correct answer is DATA DIVISION. In COBOL programming, the DATA DIVISION is used to define the data structures and variables that will be used in the program. It specifies the names, types, and lengths of the data items. The DATA DIVISION is responsible for declaring and organizing the data that the program will work with, and it is an essential part of any COBOL program. The other divisions mentioned in the question (IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, and PROCEDURE DIVISION) are also important divisions in COBOL, but they serve different purposes than the DATA DIVISION.
11.
Every Data name used in the program must be defined in PROCEDURE DIVISION.
Correct Answer
B. False
Explanation
In a program, not every data name used needs to be defined in the PROCEDURE DIVISION. Data names can be defined in other divisions such as the DATA DIVISION or FILE SECTION. Therefore, the statement "Every Data name used in the program must be defined in PROCEDURE DIVISION" is false.
12.
PERFORM with ________ phase executes the number of times specified by the value in identifier or Integer.
A. UNTIL
B. THRU
C. END-PERFORM
D. TIMES
Correct Answer
TIMES, D, D. TIMESÂ
Explanation
The correct answer is D. TIMES. The PERFORM with TIMES phase executes the number of times specified by the value in identifier or Integer. In this case, the value in identifier or Integer is D, indicating that the PERFORM statement will be executed D number of times. The second D in the answer choice is likely a typo or repetition.