Memory Management Techniques Interview Questions
What is memory management technique in COBOL?
Memory management techniques refer to how programs allocate, use, and release memory during the program execution.
What are the different memory management techniques available in COBOL?
Below are the list of memory management techniques available in COBOL -
- REDEFINES
- RENAMES
- SYNCHRONIZED Clause
- Computational Items (USAGE Clause)
REDEFINES -
What is Redefines clause?
REDEFINES defines a new variable for the existing variable, which means two variables share the same memory area.
Give some advantages of REDEFINES clause?
It is a way to declare multiple variables for a single memory area in different ways based on the requirement.
RENAMES -
What is Renames clause?
RENAMES clause regroups the existing group of items and assigns a new name. It creates another logical group by regrouping some or all elementary variables of a group.
Explain difference between renaming elementary and group data in programming?
Renaming elementary items is not possible and only renaming group items is possible.
SYNCHRONIZED Clause -
What is the sync clause?
SYNCHRONIZED clause allocates the variables at their respective natural memory boundaries (immediately after the previous allocation ends).
What slack bytes in variable declaration?
Due to the variable allocation at the word boundaries, some bytes are unused between the boundary start and the previous allocation ending. These unused bytes are called Slack bytes.
DISPLAY Computation -
What is the display computation?
DISPLAY computation uses the character form. In character form, one character equals one byte (8 bits) of storage. If no usage clause is used, then DISPLAY usage will be applied by default.
Computation (COMP) -
What is the computation or COMP?
COMP (BINARY) stores signed decimal numbers in pure binary format and applicable to numeric data items.
How is sign stored in a COMP field?
On the last byte of the value.
What is COMP SYNC?
SYNC clause explicitly aligns COMP data items at their natural word boundaries.
COMP-1 -
What is COMP-1?
COMP-1 stores the numbers as single-precision (32 bit) floating-point numbers and applicable to numeric data items.
Does the COMP-1 have PIC clause?
No
COMP-2 -
What is COMP-2?
COMP-2 stores the numbers as internal double-precision (64 bit) floating-point numbers and applicable to numeric data items.
Does the COMP-2 have PIC clause?
No
COMP-2 -
What is COMP-3?
COMP-3 (or Packed Decimal or Packed Numeric) stores the decimal numbers in a compact binary-coded decimal (BCD) format and applicable to numeric data items.
Does COMP-3 have a PIC clause?
Yes
What is the storage occupied by COMP-3?
The formula for memory calculation of the COMP-3 with n digits (variable length + 1 byte for SIGN if exists) in the declaration is -
- No. of bytes = Round ((n + 1)/2) - Where n is an odd number.
- No. of bytes = Round (n/2) - Where n is an even number.
Common Questions -
Why is S9(4) COMP needed despite knowing that COMP-3 would utilise less space?
S9(04) COMP occupies 4 bytes. S9(4) COMP-3 occupies 3 bytes.
Frequently Asked Questions -
What is the difference between COMP and COMP-3?
What is the difference between COMP-1, COMP-2 and COMP-3?
How is sign stored in Packed Decimal fields and Zoned Decimal fields?
What is the function of using renames in programming?
What is the maximum value that can be stored in S9(8) COMP?
What is the packed decimal format?
How is sign stored in a COMP-3 field?