Wednesday, September 17, 2008

Cobol Interview Questions Part-8

121. What is the difference between performing a SECTION and a PARAGRAPH?

Ans: Performing a SECTION will cause all the paragraphs that are part of the section, to be performed.

Performing a PARAGRAPH will cause only that paragraph to be performed.

122.Can I redefine an X(200) field with a field of X(100) ?

Ans: Yes.

123.What does EXIT do?

Ans: Does nothing ! If used, must be the only sentence within a paragraph.

124.Can I redefine an X(100) field with a field of X(200)?

Ans: Yes. Redefines just causes both fields to start at the same location. For example:

01 WS-TOP PIC X(1)

01 WS-TOP-RED REDEFINES WS-TOP PIC X(2).

If you MOVE '12' to WS-TOP-RED,

DISPLAY WS-TOP will show 1 while

DISPLAY WS-TOP-RED will show 12.

125.Can I redefine an X(200) field with a field of X(100) ?

Ans: Yes.

126. What do you do to resolve SOC-7 error?

Ans:Basically you need to correcting the offending data. Many times the reason for SOC7 is an un-initialized numeric item. Examine that possibility first. Many installations provide you a dump for run time abends ( it can be generated also by calling some subroutines or OS services thru assembly language). These dumps provide the offset of the last instruction at which the abend occurred. Examine the compilation output XREF listing to get the verb and the line number of the source code at this offset. Then you can look at the source code to find the bug. To get capture the runtime dumps, you will have to define some datasets (SYSABOUT etc ) in the JCL. If none of these are helpful, use judgement and DISPLAY to localize the source of error. You may even use batch program debugging tools.

127.How is sign stored in Packed Decimal fields and Zoned Decimal fields?

Ans:Packed Decimal fields: Sign is stored as a hex value in the last nibble (4 bits ) of the storage. Zoned Decimal fields: As a default, sign is over punched with the numeric value stored in the last bite.

128. How is sign stored in a comp-3 field?

Ans:It is stored in the last nibble. For example if your number is +100, it stores hex 0C in the last byte, hex 1C if your number is 101, hex 1D if the number is -101, hex 2D if the number is -102 etc...

129.How is sign stored in a COMP field ?

Ans: In the most significant bit. Bit is on if -ve, off if +ve.

130. What is the difference between COMP & COMP-3 ?

Ans: COMP is a binary storage format while COMP-3 is packed decimal format.

131. What is COMP-1? COMP-2?

COMP-1 - Single precision floating point. Uses 4 bytes. COMP-2 - Double precision floating point. Uses 8 bytes.

132. How do you define a variable of COMP-1? COMP-2?

Ans: No picture clause to be given. Example 01 WS-VAR USAGE COMP-1.

133. How many bytes does a S9(7) COMP-3 field occupy ?

Ans: Will take 4 bytes. Sign is stored as hex value in the last nibble.

General formula is INT((n/2) + 1)), where n=7 in this example.

134. How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy ?

Ans: Will occupy 8 bytes (one extra byte for sign).

135. What is the maximum size of a 01 level item in COBOL I? in COBOL II?

In COBOL II: 16777215

136. What is COMP SYNC?

Ans: Causes the item to be aligned on natural boundaries. Can be SYNCHRONIZED LEFT or RIGHT.

For binary data items, the address resolution is faster if they are located at word boundaries in the memory. For example, on main frame the memory word size is 4 bytes. This means that each word will start from an address divisible by 4. If my first variable is x(3) and next one is s9(4) comp, then if you do not specify the SYNC clause, S9(4) COMP will start from byte 3 ( assuming that it starts from 0 ). If you specify SYNC, then the binary data item will start from address 4. You might see some wastage of memory, but the access to this comp field is faster.

137. How do you reference the following file formats from COBOL programs?

Ans:Fixed Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0. Fixed Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, do not use BLOCK CONTAINS. Variable Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, BLOCK CONTAINS 0. Do not code the 4 bytes for record length in FD. i.e. JCL record length will be max record length in program + 4 Variable Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, do not use BLOCK CONTAINS. Do not code 4 bytes for record length in FD ie JCL rec length will be max rec length in pgm + 4. ESDS VSAM file - Use ORGANISATION IS SEQUENTIAL. KSDS VSAM file - Use ORGANISATION IS INDEXED, RECORD KEY IS, Alternate Record Key Is RRDS File - Use ORGANISATION IS RELATIVE, RELATIVE KEY IS Printer File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0. (Use RECFM=FBA in JCL DCB).

138. What are different file OPEN modes available in COBOL? In which modes are the files Opened to write.

Ans:Different Open modes for files are INPUT, OUTPUT, I-O and EXTEND. Of which Output and Extend modes are used to write new records into a file.

139. In the JCL, how do you define the files referred to in a subroutine?

Ans: Supply the DD cards just as you would for files referred to in the main program. 

No comments:

My Ad

.