Adsnese

Ad

Wednesday, September 17, 2008

Cobol Interview Questions Part-10

151. What are the few advantages of VS COBOL II over OS/VS COBOL?

Ans: The working storage and linkage section limit has been increased. They are 128 megabytes as supposed to 1 megabytes in OS/VS COBOL.

Introduction of ADDRESS special register.

31-bit addressing. In using COBOL on PC we have only flat files and the programs can access only limited storage, whereas in VS COBOL II on M/F the programs can access up to 16MB or 2GB depending on the addressing and can use VSAM files to make I/O operations faster

152. What are the steps you go through while creating a COBOL program executable?

Ans: DB2 pre-compiler (if embedded SQL is used), CICS translator (if CICS program), Cobol compiler, Link editor. If DB2 program, create plan by binding the DBRMs.

153. Name the divisions in a COBOL Program

Ans: Identification / Environment/ Data/ Procedure Divisions

154. What are the different data types available in COBOL?

Ans: Alpha-numeric (X) , Alphabetic (A) and numeric (9).

155. What does the INITIALIZE verb do?

Ans: Alphabetic, Alphanumeric fields & alphanumeric edited items are set to SPACES. Numeric, Numeric edited items set to ZERO. FILLER , OCCURS DEPENDING ON items left untouched

156. What is the difference between a 01 level and 77 levels?

Ans: 01 level can have sublevels from 02 to 49. 77 cannot have sublevel.

157. What are 77 levels used for?

Ans: Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themselves.

158. What is 88 level used for?

Ans: For condition names.

159. What is level 66 used for?

Ans: For RENAMES clause.

160. What does the IS NUMERIC clause establish?

Ans: IS NUMERIC can be used on alphanumeric items, signed numeric & packed decimal items and unsigned numeric & packed decimal items. IS NUMERIC returns TRUE if the item only consists of 0-9. However, if the item being tested is a signed item, then it may contain 0-9, + and - .

161. Is compute w=u a valid statement?

Ans: Yes, it is. It is equivalent to move u to w.

162. In the above example, when will you prefer compute statement over the move statement?

Ans: When significant left-order digits would be lost in execution, the COMPUTE statement can detect the condition and allow you to handle it. The MOVE statement carries out the assignment with destructive truncation. Therefore, if the size error is needs to be detected, COMPUTE will be preferred over MOVE. The ON SIZE ERROR phrase of COMPUTE statement, compiler generates code to detect size-overflow.

163. What happens when the ON SIZE ERROR phrase is specified on a COMPUTE statement?

Ans: If the condition occurs, the code in the ON SIZE ERROR phrase is performed, and the content of the destination field remains unchanged. If the ON SIZE ERROR phrase is not specified, the assignment is carried out with truncation. There is no ON SIZE ERROR support for the MOVE statement.

164. How will you associate your files with external data sets where they physically reside?

Ans: Using SELECT clause, the files can be associated with external data sets. The SELECT clause is defined in the FILE-CONTROL paragraph of Input-Output Section that is coded Environment Division. The File structure is defined by FD entry under File-Section of Data Division for the OS.

165. How will you define your file to the operating system?

Ans: Associate the file with the external data set using SELECT clause of INPUT-OUTPUT SECTION. INPUT-OUTPUT SECTION appears inside the ENVIRONMENT DIVISION.

166. Explain the use of Declaratives in COBOL?

Ans: Declaratives provide special section that are executed when an exceptional condition occurs. They must be grouped together and coded at the beginning of procedure division and the entire procedure division must be divided into sections. The Declaratives start with a USE statement. The entire group of declaratives is preceded by DECLARIVES and followed by END DECLARITIVES in area A. The three types of declaratives are Exception (when error occurs during file handling), Debugging (to debug lines with 'D' coded in w-s section) and Label (for EOF or beginning...) declaratives.

167. How do you define a table/array in COBOL?

Ans:

01 ARRAYS.

05 ARRAY1 PIC X(9) OCCURS 10 TIMES.

05 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX.

168. Can the OCCURS clause be at the 01 level?

Ans: No

169. A statically bound subprogram is called twice. What happens to working-storage variables?

Ans:The working-storage section is allocated at the start of the run-unit and any data items with VALUE clauses are initialized to the appropriate value at the time. When the subprogram is called the second time, a working-storage items persist in their last used state. However, if the program is specified with INITIAL on the PROGRAM-ID, working-storage section is reinitialized each time the program is entered.

170. Significance of the COMMON Attribute ?

Ans:COMMON attribute is used with nested COBOL programs. If it is not specified, other nested programs will not be able to access the program. PROGRAM-ID. Pgmname is COMMON PROGRAM.

171. In which division and section, the Special-names paragraph appears?

Ans: Environment division and Configuration Section.

172. What is the LOCAL-STORAGE SECTION?

Ans:Local-Storage is allocated each time the program is called and is de-allocated when the program returns via an EXIT PROGRAM, GOBACK, or STOP RUN. Any data items with a VALUE clauses are initialized to the appropriate value each time the program is called. The value in the data items is lost when the program returns. It is defined in the DATA DIVISION after WORKING-STORAGE SECTION

173. What does passing BY REFERENCE mean?

Ans:When the data is passed between programs, the subprogram refers to and processes the data items in the calling program's storage, rather than working on a copy of the data. When

CALL . . . BY REFERENCE identifier. In this case, the caller and the called share the same memory.

174. What does passing BY CONTENT mean?

Ans:The calling program passes only the contents of the literal, or identifier. With a CALL . . . BY CONTENT, the called program cannot change the value of the literal or identifier in the calling program, even if it modifies the variable in which it received the literal or identifier.

175. What does passing BY VALUE mean?

Ans:The calling program or method is passing the value of the literal, or identifier, not a reference to the sending data item. The called program or invoked method can change the parameter in the called program or invoked method. However, because the subprogram or method has access only to a temporary copy of the sending data item, those changes do not affect the argument in the calling program. Use By value, If you want to pass data to C program. Parameters must be of certain data type.

176. What is the default, passing BY REFERENCE or passing BY CONTENT or passing BY VALUE?

Ans: Passing by reference (the caller and the called share the same memory).

177. Where do you define your data in a program if the data is passed to the program from a Caller program?

Ans: Linkage Section 

No comments:

My Ad

.