Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

search topic

Showing posts with label cobol interview questions. Show all posts
Showing posts with label cobol interview questions. Show all posts

Monday, October 6, 2008

Cobol Interview Questions Part-9

140. Can you REWRITE a record in an ESDS file? Can you DELETE a record from it?

Ans: Can rewrite(record length must be same), but not delete.

141.What is file status 92?

Ans: Logic error. e.g., a file is opened for input and an attempt is made to write to it.

142.What is file status 39?

Ans: Mismatch in LRECL or BLOCKSIZE or RECFM between your COBOL pgm & the JCL (or the dataset label). You will get file status 39 on an OPEN.

143.What is Static, Dynamic linking ?

Ans: In static linking, the called subroutine is link-edited into the calling program , while in dynamic linking, the subroutine & the main program will exist as separate load modules. You choose static/dynamic linking by choosing either the DYNAM or NODYNAM link edit option. (Even if you choose NODYNAM, a CALL identifier (as opposed to a CALL literal), will translate to a DYNAMIC call).

A statically called subroutine will not be in its initial state the next time it is called unless you explicitly use INITIAL or you do a CANCEL. A dynamically called routine will always be in its initial state.

144.Explain NEXT and CONTINUE verbs for file handling.

Ans: A The Continue verb is used for a situation where there in no EOF condition. i.e. The records are to be accessed again and again in a file. Whereas in the next verb the indexed file is accessed sequentially, whence when index clause is accessed sequentially read next record command is used.

145. What is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY)? (applicable to only MVS/ESA).

Ans: These are compile/link edit options. AMODE - Addressing mode. RMODE - Residency mode.

AMODE(24) - 24 bit addressing. AMODE(31) - 31 bit addressing. AMODE(ANY) - Either 24 bit or 31 bit addressing depending on RMODE. RMODE(24) - Resides in virtual storage below 16 Meg line. Use this for 31 bit programs that call 24 bit programs. (OS/VS Cobol pgms use 24 bit addresses only). RMODE(ANY) - Can reside above or below 16 Meg line.

146. What compiler option would you use for dynamic linking?

DYNAM.

147. What is SSRANGE, NOSSRANGE ?

Ans: These are compiler options w.r.t subscript out of range checking. NOSSRANGE is the default and if chosen, no run time error will be flagged if your index or subscript goes out of the permissible range.

148. How do you set a return code to the JCL from a COBOL program?

Ans: Move a value to RETURN-CODE register. RETURN-CODE should not be declared in your program.

149. How can you submit a job from COBOL programs?

Ans: Write JCL cards to a dataset with

//xxxxxxx SYSOUT=(A,INTRDR) where 'A' is output class, and dataset should be opened for output in the program. Define a 80 byte record layout for the file.

150. What are the differences between OS VS COBOL and VS COBOL II?

Ans:

  1. OS/VS Cobol pgms can only run in 24 bit addressing mode, VS Cobol II pgms can run either in 24 bit or 31 bit addressing modes allowing program to address above 16 Meg main storage line.
  2. Report writer is supported only in OS/VS Cobol.
  3. USAGE IS POINTER is supported only in VS COBOL II.
  4. Reference modification eg: WS-VAR(1:2) is supported only in VS COBOL II.
  5. COBOL II introduces new features (EVALUATE, SET ... TO TRUE, CALL ... BY CONTEXT, etc)
  6. Scope terminators are supported in COBOL II.
  7. OS/VS Cobol follows ANSI 74 stds while VS COBOL II follows ANSI 85 stds.
  8. Under CICS Calls between VS COBOL II programs are supported.
  9. COBOL II supports structured programming by using in-line PERFORM 's.
  10. COBOL II does not support old features (READY TRACE, REPORT-WRITER, ISAM, etc.).
  11. In non-CICS environment, it is possible. In CICS, this is not possible.

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

Cobol Interview Questions Part-11

178. Define the structure of a COBOL subroutine.

Ans: The PROCEDURE DIVISION header must have a using a phrase, if the data needs to be passed to the program. The operands of the USING phrase must be defined in the LINKAGE SECTION as 01-level or 77-level entries. No VALUE clause is allowed unless the data defined is a condition name.

If the program needs to be returned to the CALLER, use EXIT PROGRAM statement at the end of the program. GOBACK is an alternative, but is nonstandard.

179. What is difference between next sentence and continue

Ans: NEXT SENTENCE gives control to the verb following the next period. CONTINUE gives control to the next verb after the explicit scope terminator. (This is not one of COBOL II's finer implementations). It's safest to use CONTINUE rather than NEXT SENTENCE in COBOL II. CONTINUE is like a null statement (do nothing) , while NEXT SENTENCE transfers control to the next sentence (!!) (A sentence is terminated by a period). Check out by writing the following code example, one if sentence followed by 3 display statements: If 1 > 0 then next sentence end if display 'line 1' display 'line 2'. display 'line 3'. *** Note- there is a dot (.) only at the end of the last 2 statements, see the effect by replacing Next Sentence with Continue ***

180. What is the difference between Structured Cobol Programming and Object Oriented COBOL programming?

Ans: Structured programming is a Logical way of programming using which you divide the functionality's into modules and code logically. OOP is a Natural way of programming in which you identify the objects, first then write functions and procedures around the objects. Sorry, this may not be an adequate answer, but they are two different programming paradigms, which is difficult to put in a sentence or two.

181. PIC S9(4)COMP is used in spite of COMP-3 which occupies less space why?

Ans:S9(4) COMP uses only 2 bytes. 9(4) COMP-3 uses 3 bytes. 3 bytes are more than 2 bytes. Hence COMP is preferred over COMP-3 in this case.

182. How many number of bytes and digits are involved in S9(10) COMP?

Ans: 8 bytes (double word) and 10 digits. Up to 9(9) comp use full word, up to 9(18) comp needs double word.

183. How many numbers of decimal digits are possible, when the amount of storage allocated for a USAGE COMP item is a) half word b) full word c) double word?

Ans: 2 bytes (halfword) for 1-4 Digits 4 bytes (fullword) for 5-9

8 bytes (doubleword) for 10-18

184. What is a scope terminator? Give examples.

Ans: Scope terminator is used to mark the end of a verb e.g. EVALUATE, END-EVALUATE , IF, END-IF.

185. How many dimensions are allowed for a table?

Ans: 7

186. How many subscripts or indexes are allowed for an OCCURS clause?

Ans: 7

187. Why cannot Occurs be used in 01 level?

Ans: Because, Occurs clause is there to repeat fields with the same format, but not the records.

188. Can a REDEFINES clause be used along with an OCCURS clause?

Ans: Yes, if the REDEFINES clause is subordinate to OCCURS clause.

189. Can you specify PIC clause and a VALUE with an OCCURS clause? Will the following code compile without errors?

01 WS-TABLE.

03 WS-TABLE-EL OCCURS 5 TIMES PIC X(1) VALUE SPACES.

Ans: Yes, the code will compile without any errors.

190. What would be the output, when the following code is executed?

01 WS-TABLE.

03 WS-TABLE-EL OCCURS 5 TIMES PIC X(1) VALUE 'AAAAA'.

Ans:It cannot be executed because the code will compile with error ' "VALUE" literal "'AAAA'" exceeded the length specified in the "PICTURE" definition'.

191. 01 WS-TABLE.

03 WS-TABLE-EL OCCURS 5 TIMES PIC X(1) VALUE 'A'.

03 WS-EX REDEFINES WS-TABLE-EL PIC X(5). What can you expect?

Ans: Compile error. Direct Redefinition of OCCURS clause is not allowed.

192. 01 WS-TABLE.

03 WS-TABLE-EL OCCURS 5 TIMES.

04 FILLER-X PIC X(1) VALUE 'A'.

04 WS-EX REDEFINES FILLER-X PIC X(1).

What would be the output of DISPLAY WS-TABLE?

Ans: 'AAAAA'. The code will compile and execute as Redefinition of an item subordinate to OCCURS clause.

193. Can a SEARCH be applied to a table which does not have an INDEX defined?

Ans: No, the table must be indexed.

194. What is the difference between SEARCH and SEARCH ALL?

Ans: SEARCH - is a serial search.

SEARCH ALL - is a binary search & the table must be sorted ( ASCENDING/DESCENDING KEY clause to be used & data loaded in this order) before using SEARCH ALL.

195. What should be the sorting order for SEARCH ALL?

Ans:It can be either ASCENDING or DESCENDING. ASCENDING is default. If you want the search to be done on an array sorted in descending order, then while defining the array, you should give DESCENDING KEY clause. (You must load the table in the specified order).

196. What is binary search?

Ans:Search on a sorted array. Compare the item to be searched with the item at the center. If it matches, fine else repeat the process with the left half or the right half depending on where the item lies.

197. Can a SEARCH be applied to a table which does not have an INDEX defined?

Ans: No, the table must be indexed.

198. A table has two indexes defined. Which one will be used by the SEARCH verb?

Ans: The index named first will be used, by Search.

199. What are the different rules applicable to perform a binary SEARCH?

Ans: The table must be sorted in ascending or descending order before the beginning of the SEARCH. Use OCCURS clause with ASC/DESC KEY IS dataname1 option

The table must be indexed. There is no need to set the index value. Use SEARCH ALL verb

200. How does the binary search work?

Ans: First the table is split into two halves and in which half, the item need to be searched is determined. The half to which the desired item may belong is again divided into two halves and the previous procedure is followed. This continues until the item is found. SEARCH ALL is efficient for tables larger than 70 items.