Wednesday, April 29, 2009

Cobol interview questions


What are main the differences between COBOL II and COBOL language?

Following are the various differences between COBOL II and COBOL language:

By using in line PERFORMs and explicit scope terminators COBOL II supports structured programming, COBOL II introduces many new features such as (SET .. TO TRUE, EVALUATE, CALL .. BY CONTEXT, etc and many more), COBOL II allows programs to be loaded and addressed above the sixteen megabyte line, some of the old features are not supported by COBOL II such as (READY TRACE, ISAM, REPORT-WRITER, etc.).

COBOL II also offers enhanced CICS support as well.

What is the meaning of an explicit scope terminator?




A scope terminator mainly brackets its preceding verb, for example IF .. END-IF, so that all statements which are between the verb and its scope terminator will be grouped together. There is some other common COBOL II verbs as well for example EVALUATE, READ, SEARCH, STRING, and PERFORM.

When would you use an in line PERFORM and what does it mean?

The COBOL II statements PERFORM and END-PERFORM group all the statements of COBOL II between them. PERFORM or PERFORM THRU a paragraph are the statements that we use in COBOL and are equivalent to PERFORM and END-PERFORM statements of COBOL II. The In line PERFORMs will only work if there are no internal GO TOs in the code, not even to an exit. Page length should not be exceeded while using in line PERFORM for readability otherwise it will reference other PERFORM paragraphs.

What the various differences are between CONTINUE and NEXT SENTENCE statements?

The NEXT SENTENCE statement basically gives control to the verb which is following the next period. Where as the CONTINUE statement gives control to that verb which comes after the explicit scope terminator. (This is definitely not a great implementation in COBOL II). So there fore in COBOL II using CONTINUE is safest rather than using NEXT SENTENCE.

Which COBOL construct can be used in place of COBOL II EVALUATE statement?

IN COBOL II we use EVALUATE, but in COBOL the nested IF THEN ELSE statements can be used in place of EVALUATE.

When we use EVALUATE it constructs case structure. This can be replaced by using nested if statements. Using nested if statements are simple and also the complexity is far less in this.

What are the various things which are removed from COBOL for the implementation of COBOL II?




Following is the list of some statements which are removed from COBOL, for the COBOL II implementation:

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

By comparing call by context to other calls explain it?

In a normal call the parameters which are passed can be modified, but in a call by context the parameters passed are protected and the program which called those parameters can’t modify them.

What does the term linkage section stands for?

The part of a called program that 'links' or maps to data items in the calling program's working storage section is called the linkage section. The linkage section is basically the part of the called program where we define the share items.

By using linkage section we can pass values to the program by using JCL. For example: using dates for processing the data in the program.


In a table definition what’s the difference between an index and a subscript?

An index is basically a register item. Its range is outside the program's working storage section. Normally we SET an index to a value and DOWN BY value and SET it UP BY value.

The working storage data definition item is called a subscript, it is typically a PIC (999) where we move the value to the subscript and then we do decrement or increment by SUBTRACT FROM and ADD TO statements.

If a table is being passed via linkage, which is most preferable - an index or a subscript?




My dear friend why don’t you understand, passing an index via linkage is not possible. Calling programs working storage sections don’t have index as their part. The persons, who've made this mistake, will definitely appreciate this lesson.

What are various differences between an external and an internal sort, explain the both the pros and cons, the syntax of internal sort etc?

An external sort does not performed by the COBOL; it is mainly executed through JCL and PGM=SORT command. We can understand this without any need of using code reference. Whereas an internal sort which is performed by the COBOL, uses two different syntaxes: the first one is: USING, GIVING sorts are equivalent to external sorts with no more extra file processing. The second syntax is: INPUT PROCEDURE, OUTPUT PROCEDURE sorts permit for records manipulation after and/or before the sort.

Alternative answer:


1. The external sort is used in JCL while internal sort is used in COBOL application programs.



2. External sort uses the DFSORT mechanism while internal sort uses work files mechanism.



3. The internal sort is more easy to use than external sort.



4. The External sort is less flexible as compared to internal sort as data can be altered or updated before and after performing internal sort whereas this cannot be done in external sort.


What is the difference between the usage of comp-3 and comp?




Explain the various other COBOL usages as well?

Comp-3 specifies packed decimal whereas Comp is a binary usage. Other most common usages are display and binary. The default usage is the Display. The fastest and ideal numeric data type for the machine it runs on is the Comp. binary is mainly used for IBM Mainframes and packed is used in AS400's.

In which situations the scope terminator is mandatory?

For EVALUATE and in-line PERFORMS statements the scope terminators are mandatory. For better readability, it's always recommended that we use scope terminators explicitly. Also using scope terminators is a good coding practice.

When is the condition tested in a perform statement of COBOL II, is it before or after the perform execution?

We can add the optional clause WITH TEST AFTER or WITH TEST BEFORE in COBOL II to all perform statements. Normally the test is performed before the perform statement by default.

Is the order of the WHEN clauses significant in an EVALUTE statement?

Yes it’s absolutely correct. Since the WHEN clause’s evaluation proceeds generally from top to bottom and their cycle can decide results.

What default value(s) is used for an INITIALIZE statement and for an override of the default which keyword is used?

The spaces are moved to alphabetic fields and zeros to alphanumeric fields by using INITIALIZE. To override these defaults the REPLACING option can be used.

What does LENGTH stands for in COBOL II?




a special register which tells the length of a group or elementary item is called LENGTH. We declare LENGTH normally in working storage section. In COBOL, the LENGTH is a fundamental function which returns amount of characters in any variable.

What are the various differences between a sequential search and binary search? Which commands are the pertinent COBOL commands?

The searching begins in a table from top to bottom in a sequential search, so there is no need of elements to be in a exact sequence. Whereas as compared to binary search the key values in a table must be in ascending or descending order. The table is divided into two equal parts to search for equal to, greater than or less than conditions until the element is found. For larger tables the binary search is the most recommended because it is faster, whereas sequential search is better for smaller tables. The SEARCH ALL keyword is used for binary searches, whereas the SEARCH keyword is for sequential.

What is the benefit of using REPLACING option in a copy statement?

By using the REPLACING option in a copy statement the same copy can be used any number of times in the identical code by altering the replace value

Alternative answer: we can use same block of code for different programs which have mostly all things in common except a few variables in that block of code by using the Replacing option in a COPY verb. The replacing option provides the great feature of reusability of code. By using this option we do not need to write the same code again and again.

What is the upper limit of the variable length record?




Basically the upper limit of Variable Length Record changes from Computer to Computer, so we can says that there is no specific limit of the variable length record.

But you can say 4096k is the max variable length record

Tell me that does I can use Redefines clause at 01 level?

Yes, the Redefines clause can be used at Level 01. But remember that the variable which we are redefining at level 01 must also be declared at the Level. We can redefine a part of the variable only at 01 level instead of having to redefine for the complete length.

The redefine clause can be used in 01 level in working storage section.

But it cannot be used in the File Section in a level 01 entry.

In File section can Redefines clause be used?

To redefine a group level item or elementary item the redefines clause is used, it is true in all levels.

In file section the REDEFINES clause cannot be used in a level 01 entry.

Related Articles :


Stumble
Delicious
Technorati
Twitter
Facebook

0 comments:

Post a Comment

Career Launchers!!!

Note:

This blog can be viewed using all the browsers but can be best viewed in Mozilla Browser.
 

Career Launchers!!! Copyright © 2010 LKart Theme is Designed by Lasantha