Data Movement Statements Interview Questions
Initialize Statement -
What does the INITIALIZE verb do?
INITIALIZE sets all elementary variables under group variable with system-defined initial values based on their data types.
What is the importance of INITIALIZE verb?
It is a convenient way to reset the full copybook, and group variable, ensuring that they start with predictable values.
What are the defaults values of various data types when INITIALIZE statement is used?
Below are the default values according to the data types -
Data type | Default value |
---|---|
Numeric | ZEROES |
Alphabetic, Alpha-numeric | SPACES |
How the INITIALIZE works in COBOL program?
- For NUMERIC fields (like PIC 9), they are set to zeros.
- For ALPHANUMERIC fields (like PIC X), they are set to spaces.
- For ALPHABETIC fields (like PIC A), they are set to spaces.
- For ALPHA-NUMERIC EDITED and NUMERIC EDITED fields, they retain their specific edit symbols, and other positions are set to zeros or spaces as appropriate.
Does INITIALIZE initializes the FILLER also? If yes, how?
No. FILLER items are not initialized by the INITIALIZE statement.
Move Statement -
What is a move statement in COBOL?
MOVE statement is used to transfer data from the source data item to the target data item. The sending and receiving data items should be declared with compatible data type to avoid data transferring errors.
What are the different types of the MOVE statement?
MOVE statement divided into four types based on its usage -
- Simple MOVE
- Group MOVE
- MOVE Corresponding
- MOVE Reference Modification
What is simple MOVE?
It is used to move the value of the sending item(s) to the receiving item.
What is the group MOVE?
It is used to move data between two groups whose elementary items are in the same order.
What is corresponding MOVE?
It is used to move data between two groups whose elementary items are not in the same order. However, the elementary items in both groups should have the same names and data type.
What is reference Modification?
It is a special-purpose MOVE that moves a portion of data from the sending item to the receiving item.
Can we move the data from smaller element to larger element?
Yes
Can we move the data from larger element to small element in COBOL?
Yes. But the excess data gets truncated.
Can we move alphabetic item to numeric item?
Not Possible
Can we move numeric to alphabetic item?
Not Possible
Can we move alphanumeric item to numeric item?
Yes. If the data is completly numeric.
Can we move numeric item to alphanumeric item?
Yes
What is SOC-7 abend?
Moving non numeric data to numeric variables causes SOC-7 abend.
What do you do to resolve SOC-7 error?
Find out the compile listing that displays in the abend information. Find the near by statement of the compile listing. Check the declarations of the variables used in MOVE statement and use the compatible data types to resolve the issue.
Frequently Asked Questions -
Mention the importance of INITIALIZE verb?
What is the significance of the INITIALIZE verb?
What is the purpose of the INITIALIZE verb in COBOL, and when would you use it?
What will happen if you initialize a field which has Value clause?
Define the term "initialise"? When would you use it?
Describe some rules in INITIALIZE statement?
Explain the performance of using move statements in programming?