Saturday, April 18, 2009

COBOL Interview Questions FAQs and more 1

I was preparing for an Mainframe cobol interview. So i thought of jot down some of the important questions which comes to my mind as and when i revise the topic. It might be useful for someone some day.

Let us start with the bare basics and then proceed to higher levels.

1) Cobol full form - Acronym for COmmon Business-Oriented Language

2) Structure of cobol program

IDENTIFICATION DIVISION
PROGRAM-ID.
AUTHOR
INSTALLATION
DATE-WRITTEN
DATE-COMPILED
SECURITY
.
ENVIRONMENT DIVISION
CONFIGURATION SECTION
SOURCE-COMPUTER
OBJECT-COMPUTER
SPECIAL-NAMES
INPUT-OUTPUT SECTION.
FILE CONTROL.
I-O-CONTROL.
.
DATA DIVISION
FILE SECTION.
WORKING-STORAGE SECTION.
.
PROCEDURE DIVISION

3) PICTURE CLAUSE CODE CHARACTER

9 ==> Indicates a numeral
X ==> Indicates an alpha numeric character
A ==> Alphabet or a space
V ==> Assumed decimal point
P ==> Assumed decimal point (point lies outside the data item)
S ==> Indicates a signed data item

4) What is VALUE clause in cobol

Defines an initial value of a data item. Normally used for initialization.
eg. 01 VAR-1 PIC X(5) VALUE SPACES

5) What is a FILE SECTION in cobol

Contains a file description entry followed by one or more record descrition entries for each of the files used in a program.

6) What are the edit characters for numeric data in cobol?

The following characters can be used in PICTURE clause to indicate numeric editing in cobol

Z ==> Used for zero suppression and replaced by space characters

* ==> Same as Z but instead of blanks the zeroes are suppressed by replacing it with *

$ ==> Single currency sign can appear at the leftmost position of a picture.

- ==> a minus sign can appear in the left or right most part of pic clause. If value of the item is negative then a minus sign is inserted otherwise a space is inserted.

+ ==> same as a minus sign. But if the item is negative, a minus sign is inserted instead of +.

CR ==> Can appear in the right most position of a pic clause only. It will appear only if item is negative. Otherwise two spaces will be added.

DB ==> Can appear in the right most position of a pic clause only. It will appear only if item is negative. Otherwise two spaces will be added.

. ==> To indicate a decimal point and cannot appear more than once. Both period and V cannot appear in the same picture.

, ==> Acts as an insertion character and inserted wherever it appears. There can be more than one comman in a picture. if we move 246 to *,***,** then we will get ****2,46 (The first comma will be replaced with space in this case and all similar cases)

B ==> For inserting blanks. Can be more than one blank

0 ==> A zero appering i a picture will be treated in the same way as a B except that 0 will be inserted.

/ ==> Can appear anywhere in the picture.

BLANK WHEN ZERO ==> It is an editing clause which may be used along with a picture. This will set the entire data item to blanks if the value is zero. Cannot be used with *.

7) What is a USAGE clause. What are the common usages?

Computer can store data in more than one internal form. A programmer can specify the internal form of data so as to facilitate the use of the data item more efficiently. Broadly there are two kinds of internal reprecentation. Computational and display.

The popular computational usages are

COMP
COMP-1
COMP-2
COMP-3

8) What is COMP, COMP-1, COMP-2 AND COMP-3?

COMP ==> Pure binary. Depending on size of data item, it can be stored either in a half word or in full word.

COMP-1 ==> Represented in one word in the floating point form. The number is actually represented in hexadecimal. It is suitable for arithmatic operations. Picture clause cannot be specified for COMP-1 items.

COMP-2 ==> Usage is same as comp1 but instead of one word, COMP-2 is represented internally in two words. The advantage is increased precission of the data which means more significant digits. A picture clause cannot be specified for COMP-2 items.

COMP-3 ==> In this form the numeric data is represented in the decimal form but one digit takes half a byte. The sign is stored seperately as the rightmost half byte regardless of whether S is specified in the PICTURE or not. The hexadecimal number C or F denotes a positive sign and the hexadecimal number D denotes a negative sign.

For more COBOL FAQs, click the relevant links in this page.

No comments: