1.
1). WORKING-STORAGE SECTION.
01 WS-NUM1 PIC 9(03) VALUE 100.
01 WS-NUM2 PIC 9(02).
01 WS-NUM3 PIC 9(02).
PROCEDURE DIVISION.
MOVE 200 TO WS-NUM2
MOVE WS-NUM1 TO WS-NUM3
MOVE WS-NUM2 TO WS-NUM3
DISPLAY WS-NUM3
What is output stored in variable ws-num3?
Correct Answer
C. 00
Explanation
The output stored in variable WS-NUM3 is "00". This is because the value of WS-NUM1 is 100, and it is moved to WS-NUM3. Then the value of WS-NUM2 is moved to WS-NUM3, which overwrites the previous value. Since WS-NUM2 has a value of 200, the final value of WS-NUM3 becomes "00".
2.
3). WORKING-STORAGE SECTION.
01 WS-NUM1 PIC 9(03) VALUE 100.
PROCEDURE DIVISION.
MOVE 200 TO WS-NUM1
INITIALIZE WS-NUM1
DISPLAY WS-NUM1 .
What is output stored in variable ws-num1
Correct Answer
A. A).000
Explanation
The output stored in variable WS-NUM1 is "000". This is because the value of WS-NUM1 is initially set to 100, but then it is initialized to its default value, which is all zeros. Therefore, when it is displayed, it will show "000".
3.
4).. WORKING-STORAGE SECTION.
01 WS-NUM1 PIC S9(03) SIGN IS LEADING SEPARATE.
HOW MANY BYTES WS-NUM1 WILL OCCUPY?
Correct Answer
B. B).4
Explanation
The WORKING-STORAGE SECTION is used to declare variables and data structures that are used within the program. In this case, the variable WS-NUM1 is declared with a PICTURE clause specifying that it is a signed numeric field with 3 digits and the sign is leading separate. In COBOL, each digit occupies one byte of storage, and the sign takes up an additional byte. Therefore, WS-NUM1 will occupy 4 bytes in total.
4.
2). WORKING-STORAGE SECTION.
01 WS-NUM1 PIC 9(03) VALUE 100.
01 WS-NUM2 PIC 9(03).
01 WS-NUM3 PIC 9(03).
PROCEDURE DIVISION.
MOVE 200 TO WS-NUM2
STOP RUN
MOVE WS-NUM1 TO WS-NUM3
MOVE WS-NUM2 TO WS-NUM3
DISPLAY WS-NUM1.
Correct Answer
D. D).NOTHING WILL BE DISPLAYED IN SPOOL
Explanation
The program starts by initializing WS-NUM1 with a value of 100. Then, it moves a value of 200 to WS-NUM2 and stops the program. Since the program stops before reaching the DISPLAY statement, nothing will be displayed in the spool.
5.
5). WORKING-STORAGE SECTION.
01 WS-NUM1 PIC +9(3).
PROCEDURE DIVISION.
MOVE -120 TO WS-NUM1
DISPLAY WS-NUM1
Correct Answer
A. A).-120
Explanation
The correct answer is A) -120. In the given code, the value -120 is being moved to the variable WS-NUM1 in the working-storage section. After that, the value of WS-NUM1 is displayed, which will be -120. Therefore, the correct answer is -120.
6.
6).OCCURS CAN BE DEFINED IN 01 LEVEL NO .TRUE OR FALSE?
Correct Answer
B. False
Explanation
The statement "OCCURS CAN BE DEFINED IN 01 LEVEL NO" is false. In COBOL programming, the OCCURS clause is used to define arrays or tables, and it can be defined at the 01 level or any other level in the data division. Therefore, the correct answer is false.
7.
INDEX NAME SHOULD BE DEFINED IN WORKING-STORAGE SECTION?
Correct Answer
B. False
Explanation
The index name does not need to be defined in the working-storage section. In COBOL, the index name is typically defined within the procedure division using the INDEXED BY phrase in the OCCURS clause of a table declaration. This allows the index to be associated with a specific table and used for accessing and manipulating data within that table. Therefore, the correct answer is false.
8.
ORGANIZATION FOR KSDS FILE?
Correct Answer
A. A).INDEXED
Explanation
An organization for a KSDS (Key Sequenced Data Set) file refers to how the data is structured and accessed within the file. The correct answer, A) INDEXED, indicates that the file is organized using an index structure. This means that the file contains a separate index that allows for efficient random access to the data based on the key values. This organization is suitable for files where quick access to specific records is required.
9.
WORKING-STORAGE SECTION.
01 WS-PGM-NAME PIC X(8) VALUE ‘PGMNAME’.
PROCEDURE DIVISION.
CALL WS-PGM-NAME .
Correct Answer
B. B).DYNAMIC CALL
Explanation
The given code snippet does not include any explicit CALL statement to a specific program. Instead, it calls a data item named WS-PGM-NAME, which suggests that the program name is determined dynamically at runtime. Therefore, the correct answer is B) DYNAMIC CALL.
10.
WORKING-STORAGE SECTION.
01 WS-NUM1 PIC 9(2) VALUE 1.
PROCEDURE DIVISON.
MOVE 5 TO WS-NUM1
PERFORM 2100-PARA
THRU 2100-PARA-EXIT
UNTIL WS-NUM1 < 4
HOW MANY TIMES 2100-PARA WILL BE EXECUTED
Correct Answer
C. C).0
Explanation
The value of WS-NUM1 is initially set to 1 in the working-storage section. Then, in the procedure division, the value of WS-NUM1 is changed to 5 using the MOVE statement. After that, the program enters a loop where it performs the 2100-PARA section until WS-NUM1 is less than 4. However, since the value of WS-NUM1 is already 5, the loop condition is not met and the 2100-PARA section is not executed at all. Therefore, the answer is C).0
11.
WORKING-STORAGE SECTION.
01 WS-NUM1 PIC S9(7)V9(4) COMP-3.
HOW MANY BYTES WS-NUM1 FIELD WILL OCCUPY?
Correct Answer
B. B).6
Explanation
The WS-NUM1 field is defined as PIC S9(7)V9(4) COMP-3, which means it is a signed numeric field with a total length of 6 bytes. The "S" indicates that it is a signed field, the "9(7)" indicates that it can hold up to 7 digits before the decimal point, the "V" indicates the presence of a decimal point, and the "9(4)" indicates that it can hold up to 4 digits after the decimal point. The COMP-3 attribute indicates that it is a packed decimal representation, which requires half a byte for each digit and an additional half byte for the sign. Therefore, the WS-NUM1 field will occupy 6 bytes in total.
12.
Can I redefine an X(200) field with a field of X(100) ?
Correct Answer
A. A).YES
Explanation
Yes, it is possible to redefine an X(200) field with a field of X(100). The "redefine" statement in programming allows for the reuse of memory space by defining a new field with the same starting location as the previous field. In this case, the X(100) field can be defined to start at the same location as the X(200) field, effectively redefining it.
13.
WHAT IS LEVEL NO 88 USED FOR?
Correct Answer
B. B).CONDITION NAMES
Explanation
Level number 88 is used for condition names in COBOL. Condition names are used to define conditions or states that can be tested in a program. They are typically used in conjunction with the EVALUATE statement to perform different actions based on the condition being met. Level number 88 provides a way to define condition names in the data division of a COBOL program.
14.
What is the result of the following?
VAR1 is defined as PIC 9(7).
MOVE ‘1234567’ to VAR1
Correct Answer
A. Compilation error
Explanation
The given code will result in a compilation error because the value being moved to VAR1 is a character string '1234567', but VAR1 is defined as PIC 9(7), which means it can only hold numeric values.
15.
). How many times PARA-1 is executed when SUB is with PIC 9.
PERFORM PARA-1 VARYING SUB FROM 1 BY 1 UNTIL SUB = 10.
PARA-1.
DISPLAY SUB.
Correct Answer
C. Keep looping (as SUB WILL BECOME 0 WHEN INCREASED TO 10)
Explanation
The PERFORM statement in the given code is a loop that executes the PARA-1 paragraph multiple times. The VARYING clause is used to increment the SUB variable from 1 by 1 until it reaches 10. Therefore, the PARA-1 paragraph will be executed 10 times. The answer "Keep looping (as SUB WILL BECOME 0 WHEN INCREASED TO 10)" accurately describes the behavior of the loop.
16.
01 WS-NUM1 PIC 9(2).
01 WS-NUM2 PIC 9(2).
PROCEDURE DIVISION.
MOVE 10 TO WS-NUM1,WS-NUM2
IF WS-NUM1 = WS-NUM2
CONTINUE
ELSE
DISPLAY ‘TWO NO ARE NOT EQUAL’
END-IF.
DISPLAY ‘TWO NO ARE EQUAL’
WHAT IS THE OUTPUT OF THE ABOVE CODE?
Correct Answer
B. TWO NO ARE EQUAL
Explanation
The output of the above code will be "TWO NO ARE EQUAL". This is because the code first moves the value 10 to both WS-NUM1 and WS-NUM2 variables. Then it checks if WS-NUM1 is equal to WS-NUM2. Since both variables have the same value of 10, the condition is true and the code will display "TWO NO ARE EQUAL".
17.
01 WS-GROUP.
05 WS-A PIC 9(03).
05 WS-B PIC 9(03).
01 WS-GROUP1 REDEFINES WS-GROUP.
05 WS-C PIC 9(03).
05 WS-D PIC 9(03).
MOVE 100 TO WS-C
MOVE 200 TO WS-D
MOVE 300 TO WS-A
MOVE 400 TO WS-B
DISPLAY WS-C
Correct Answer
B. B).300
Explanation
The value of WS-C is displayed, which is 300. This is because the value of WS-C is moved from 100 to WS-C using the MOVE statement. Therefore, the correct answer is B) 300.
18.
In WRITE statement it is required to mention the record name and not the file name
Correct Answer
A. True
Explanation
The explanation for the given correct answer is that in a WRITE statement, it is necessary to specify the name of the record that is being written, rather than the name of the file. The WRITE statement is used in programming languages to write data into a file, and it requires the record name to identify the specific record that is being written. The file name is typically specified separately when opening or accessing the file. Therefore, the statement that it is required to mention the record name and not the file name in a WRITE statement is true.
19.
If A=10, B=20, C=30,D=0 Then the result of operation ______________ ADD A B TO C GIVING D
Correct Answer
A. A).60
Explanation
The given operation is "ADD A B TO C GIVING D". This means that the values of A and B are added together and the result is stored in C. Therefore, the sum of A (10) and B (20) is 30, which is stored in C. The value of D is not relevant to the operation. So, the correct answer is A).60, which represents the sum of A and B.
20.
).01 WS-STR1 PIC X(6).
01 WS-STR2 PIC X(10).
01 WS-STR3 PIC X(15).
MOVE ‘SACHIN’ TO WS-STR1
MOVE’ TENDULKAR’ TO WS-STR2
STRING WS-STR1 DELIMITED BY SIZE,
WS-STR2 DELIMITED BY SPACE INTO WS-STR3
DISPLAY WS-STR3
Correct Answer
C. SACHINTENDULKAR
Explanation
The given code declares three variables: WS-STR1, WS-STR2, and WS-STR3, all of which are character strings. The code then assigns the value "SACHIN" to WS-STR1 and "TENDULKAR" to WS-STR2 using the MOVE statement. The STRING statement is then used to concatenate WS-STR1 and WS-STR2, with WS-STR1 being delimited by its size and WS-STR2 being delimited by a space. The result is stored in WS-STR3. Finally, the code displays the value of WS-STR3, which is "SACHINTENDULKAR".