Wednesday, May 23, 2012

Cobol Interview Questions 4

Q61) What is an explicit scope terminator ?

A61) 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, EVALUATE, SEARCH and STRING.

Q62) What is an in line PERFORM ? When would you use it ? Anything else to say about it ?

A62) 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.

Q63) What is the difference between NEXT SENTENCE and CONTINUE ?

A63) 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.

Q64) What COBOL construct is the COBOL II EVALUATE meant to replace ?

A64) EVALUATE can be used in place of the nested IF THEN ELSE statements.

Q65) What is the significance of 'above the line' and 'below the line' ?

A65) 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.)

Q66) What was removed from COBOL in the COBOL II implementation ?

A66) Partial list: REMARKS, NOMINAL KEY, PAGE-COUNTER, CURRENT-DAY, TIME-OF-DAY, STATE, FLOW, COUNT, EXAMINE, EXHIBIT, READY TRACE and RESET TRACE.

Q67) Explain call by context by comparing it to other calls. ?

A67) 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.

Q68) What is the linkage section ?

A68) The linkage section is part of a called program that 'links' or maps to data items in the calling program's working storage. It is the part of the called program where these share items are defined.

Q69) What is the difference between a subscript and an index in a table definition ?

A69) 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.

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's 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.

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.

What is the difference between comp and comp-3 usage ? Explain other COBOL usage’s. ?
 Comp is a binary usage, while comp-3 indicates packed decimal. The other common usage’s are binary and display. Display is the default.

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

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.

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.

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.

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.)

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

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.

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.

2 comments:

  1. Thanks for the list of questions.
    For Real time scenario based Mainframe interview questions with good explanation,please refer
    WWW.MAINFRAMEINTERVIEW.COM

    ReplyDelete
  2. Hi guys,

    We are opening whats app group for mainframe jobs pune location only. You can join the group using link below.
    https://chat.whatsapp.com/CbtVddtlKcBJ2lwrh1BVd0

    Mention your name and organisation after joining.

    ReplyDelete