TOP 50 Cobol Interview Questions and Answers pdf fresher and experienced

Read the most frequently asked 50 top Cobol interview questions and answers for freshers and experienced.

Cobol Interview Questions and Answers PDF Experienced Freshers
1. How many sections are there in data division? 
SIX SECTIONS

1. FILE SECTION
2. WORKING-STORAGE SECTION
3. LOCAL-STORAGE SECTION
4. SCREEN SECTION
5. REPORT SECTION
6. LINKAGE SECTION

2. What is Redefines clause?
Redefines clause is used to allow the same storage allocation to be referenced by different data names.

3. What is the different between index and subscript?
Subscript refers to the array of occurrence, where as Index represents an occurrence of a table element. An index can only modified using perform, search & set. Need to have an index for a table in order to use SEARCH and SEARCH All.

4. What is the difference between Structured COBOL Programming and Object Alternativelyiented COBOL programming?
Structured programming is a Logical way of programming, you divide the functionalities into modules and code logically. OOP is a Natural way of programming; you identify the objects first, and then write functions, 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.

5. What divisions, sections and paragraphs are mandatory for a COBOL program?
IDENTIFICATION DIVISION and PROGRAM-ID paragraph are mandatory for a compilation error free COBOL program.

6. What happens when we move a comp-3 field to an edited (say z (9). ZZ-)?
The editing characters r to be used with data items with usage clause as display which is the default. When u tries displaying a data item with usage as computational it does not give the desired display format because the data item is stored as packed decimal. So if u want this particular data item to be edited u have to move it into a data item whose usage is display and then have that particular data item edited in the format desired.

7. What is the difference between external and global variables?
Global variables are accessible only to the batch program whereas external variables can be referenced from any batch program residing in the same system library.

8. What is difference between COBOL and VS COBOL II?
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.

9. Difference between next and continue clause?
The difference between the next and continue verb is that in the continue verb it is used for a situation where there in no EOF condition that is the records are to be accessed again and again in an file, whereas in the next verb the indexed file is accessed sequentially, read next record command is used.

10. What is the Importance of GLOBAL clause According to new standards of COBOL?
When any data name, file-name, Record-name, condition name or Index defined in an Including Program can be referenced by a directly or indirectly in an included program, Provided the said name has been declared to be a global name by GLOBAL Format of Global Clause is01 data-1 pic 9(5) IS GLOBAL.
StumbleUpon
Digg
Delicious
Twitter
FaceBook
LinkedIn
Google
Yahoo
MySpace
Tell Your Friend

11. What is the Purpose of POINTER Phrase in STRING command?
The Purpose of POINTER phrase is to specify the leftmost position within receiving field where the first transferred character will be stored

12. What is the LINKAGE SECTION used for?
The linkage section is used to pass data from one program to another program or to pass data from a PROC to a program.

13. Describe the difference between subscripting and indexing?
Indexing uses binary displacement. Subscripts use the value of the occurrence.

14. Differentiate COBOL and COBOL-II. (Most of our programs are written in COBOLII, so, it is good to know, how, this is different from COBOL)?
The following features are available with VS COBOL II: 1. MVS/XA and MVS/ESA support. The compiler and the object programs it produces can be run in either 24- or 31-bit addressing mode. 2. VM/XA and VM/ESA support the compiler and the object programs it produces can be run in either 24- or 31-bit addressing mode. 3. VSE/ESA supports the compiler and the object programs it produces can be run under VSE/ESA.

15. Why do we code S9 (4) comp. Inspite of knowing comp-3 will occupy less space ?
Here s9(4)comp is small integer ,so two words equal to 1 byte so totally it will occupy 2 bytes(4 words).here in s9(4) comp-3 as one word is equal to 1/2 byte.4 words equal to 2 bytes and sign will occupy 1/2 byte so totally it will occupy 3 bytes.

16. How do you code COBOL to access a parameter that has been defined in JCL? And do you code the PARM parameter on the EXEC line in JCL?
Using JCL with sysin. //sysin dd *here u code the parameters (value) to pass in to Cobol program /* and in program you use accept variable name (one accept will read one row)/.another way. 2) in jcl using parm statement ex: in exec statement parm=’john’,'david’ in Cobol pgm u have to code linkage section in that for first value you code length variable and variable name say, abc pic x(4).it will take john inside to read next value u have to code another variable in the same way above mentioned.

17. What do you feel makes a good program?
A program that follows a top down approach. It is also one that other programmers or users can follow logically and is easy to read and understand.

18. What is the difference between static call and Dynamic call?
In the case of Static call, the called program is a stand-alone program, it is an executable program. During run time we can call it in our called program. As about Dynamic call, the called program is not an executable program it can executed through the called program

19. Give some advantages of REDEFINES clause?
1. You can REDEFINE a Variable from one PICTURE class to another PICTURE class by using the same memory location.
2. By REDEFINES we can INITIALISE the variable in WORKING-STORAGE Section itself.
3. We can REDEFINE a Single Variable into so many sub variables. (This facility is very useful in solving Y2000 Problem.)

20. How to execute a set of JCL statements from a COBOL program?
Using EXEC CICS SPOOL WRITE (var-name) END-EXEC command. Var-name is a COBOL host structure containing JCL statements.

21. How do you submit JCL via a COBOL program?
Use a file //dd1 DD sysout=(*, intrdr)write your JCL to this file. Pl some on try this out.

22. What care has to be taken to force program to execute above 16 Meg line?
Make sure that link option is AMODE=31 and RMODE=ANY. Compile option should never have SIZE (MAX). BUFSIZE can be 2K, efficient enough.

23. What is the difference between SEARCH and SEARCH ALL? What is more efficient?
SEARCH is a sequential search from the beginning of the table. SEARCH ALL is a binary search, continually dividing the table in two halves until a match is found. SEARCH ALL is more efficient for tables larger than 70 items.

24. What guidelines should be followed to write a structured COBOL prgm?
1) Use ‘evaluate’ stmt for constructing cases.
2) Use scope terminators for nesting.
3) Use in line performs stmt for writing ‘do ‘constructions.
4) Use test before and test after in the perform stmt for writing do-while constructions.

25. What is Pic 9v99 Indicates?
PICTURE 9v99 is a three position Numeric field with an implied or assumed decimal point after the first position; the v means an implied decimal point.

26. What is the difference between PIC 9.99 and 9v99?
PIC 9.99 is a FOUR-POSITION field that actually contains a decimal point where as PIC 9v99 is THREE- POSITION numeric field with implied or assumed decimal position.

27. What is the difference between a DYNAMIC and STATIC call in COBOL?
To correct an earlier answer: All called modules cannot run standalone if they require program variables passed to them via the LINKAGE section. Dynamically called modules are those that are not bound with the calling program at link edit time (IEWL for IBM) and so are loaded from the program library (joblib or steplib) associated with the job. For DYNAMIC calling of a module the DYNAM compiler option must be chosen, else the linkage editor will not generate an executable as it will expect u address resolution of all called modules. A Statically called module is one that is bound with the calling module at link edit, and therefore becomes part of the executable load module.

28. How can I tell if a module is being called DYNAMICALLY or STATICALLY?
The ONLY way is to look at the output of the linkage editor (IEWL) or the load module itself. If the module is being called DYNAMICALLY then it will not exist in the main module, if it is being called STATICALLY then it will be seen in the load module. Calling a working storage variable, containing a program name, does not make a DYNAMIC call. This type of calling is known as IMPLICITE calling as the name of the module is implied by the contents of the working storage variable. Calling a program name literal

29. What is the point of the REPLACING option of a copy statement?
REPLACING allows for the same copy to be used more than once in the same code by changing the replace value.

30. What is the difference between a binary search and a sequential search? What are the pertinent COBOL commands?
In a binary search the table element key values must be in ascending or descending sequence. The table is ‘halved’ to search for equal to, greater than or less than conditions until the element is found. In a sequential search the table is searched from top to bottom, so (ironically) the elements do not have to be in a specific sequence. The binary search is much faster for larger tables, while sequential works well with smaller ones. SEARCH ALL is used for binary searches; SEARCH for sequential.

31. What is LENGTH in COBOL II?
LENGTH acts like a special register to tell the length of a group or elementary item.

32. What is SET TO TRUE all about, anyway?
In COBOL II the 88 levels can be set rather than moving their associated values to the related data item. (Web note: This change is not one of COBOL II’s better specifications.)

33. What is the default value(s) for an INITIALIZE and what keyword allows for an override of the default?
INITIALIZE moves spaces to alphabetic fields and zeros to alphanumeric fields. The REPLACING option can be used to override these defaults.

34. In an EVALUTE statement is the order of the WHEN clauses significant?
Absolutely. Evaluation of the WHEN clauses proceeds from top to bottom and their sequence can determine results.

35. In a COBOL II PERFORM statement, when is the conditional tested, before or after the perform execution?
In COBOL II the optional clause WITH TEST BEFORE or WITH TEST AFTER can be added to all perform statements. By default the test is performed before the perform.

36. When is a scope terminator mandatory?
Scope terminators are mandatory for in-line PERFORMS and EVALUATE statements. For readability, it is recommended coding practice to always make scope terminators explicit.

37. Explain the difference between an internal and an external sort, the pros and cons, internal sort syntax etc?
An external sort is not COBOL; it is performed through JCL and PGM=SORT. It is understandable without any code reference. An internal sort can use two different syntax’s: 1.) USING, GIVING sorts are comparable to external sorts with no extra file processing; 2) INPUT PROCEDURE, OUTPUT PROCEDURE sorts allow for data manipulation before and/or after the sort.

38. If you were passing a table via linkage, which is preferable - a subscript or an index?
Wake up - you haven’t been paying attention! It is not possible to pass an index via linkage. The index is not part of the calling programs working storage. Those of us, who’ve made this mistake, appreciate the lesson more than others.

39. What is the difference between a subscript and an index in a table definition?
A subscript is a working storage data definition item, typically a PIC (999) where a value must be moved to the subscript and then incremented or decrements by ADD TO and SUBTRACT FROM statements. An index is a register item that exists outside the program’s working storage. You SET an index to a value and SET it UP BY value and DOWN BY value.

40. What is the linkage section?
The linkage section is part of a called program that ‘links’ or maps to data items in the calling program are working storage. It is the part of the called program where these share items are defined.

41. Explain call by context by comparing it to other calls?
The parameters passed in a call by context are protected from modification by the called program. In a normal call they are able to be modified.

42. What was removed from COBOL in the COBOL II implementation?
Partial list: REMARKS, NOMINAL KEY, PAGE-COUNTER, CURRENT-DAY, TIME-OF-DAY, STATE, FLOW, COUNT, EXAMINE, EXHIBIT, READY TRACE and RESET TRACE.

43. What is the significance of above the line and below the line?
Before IBM introduced MVS/XA architecture in the 1980’s a program’s virtual storage was limited to 16 Megs. Programs compiled with a 24 bit mode can only address 16 Mb of space, as though they were kept under an imaginary storage line. With COBOL II a program compiled with a 31 bit mode can be ‘above the 16 Mb line. (This ‘below the line’, ‘above the line’ imagery confuses most mainframe programmers, who tend to be a literal minded group.)

44. What is the difference between NEXT SENTENCE and CONTINUE?
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 is safest to use CONTINUE rather than NEXT SENTENCE in COBOL II.

45. What is an in line PERFORM? When would you use it? Anything else you wish to say about it.
The PERFORM and END-PERFORM statements bracket all COBOL II statements between them. The COBOL equivalent is to PERFORM or PERFORM THRU a paragraph. In line PERFORMs work as long as there are no internal GO TOs, not even to an exit. The in line PERFORM for readability should not exceed a page length - often it will reference other PERFORM paragraphs.

46. What is an explicit scope terminator?
A scope terminator brackets its preceding verb, e.g. IF... END-IF, so that all statements between the verb and its scope terminator are grouped together. Other common COBOL II verbs are READ, PERFORM, and EVALUATE, SEARCH and STRING.

47. What are the differences between COBOL and COBOL II?
There are at least five differences: COBOL II supports structured programming by using in line Performs and explicit scope terminators, It introduces new features (EVALUATE, SET. TO TRUE, CALL. BY CONTEXT, etc) It permits programs to be loaded and addressed above the 16-megabyte line It does not support many old features (READY TRACE, REPORT-WRITER, ISAM, Etc.), and It offers enhanced CICS support.

48. How do you reference the following file formats from COBOL programs?
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 rec length will be max rec length in pgm + 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 i.e. 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).

49. What is COMP SYNC?
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 computational field is faster.

50. How many bytes do a S9 (7) COMP-3 field occupy?
It will take 4 bytes to occupy. Sign is stored as hex value in the last nibble. General formula is INT((n/2) + 1)), where n=7 in this example.


0 comments:

Post a Comment