Thursday, May 24, 2012

Cobol Interview Questions 6

How do you declare a host variable (in COBOL) for an attribute named Emp-Name of type VARCHAR(25) ?
01 EMP-GRP. 49 E-LEN PIC S9(4) COMP. 49 E-NAME PIC X(25).

What is Comm ?
COMM - HALF WORD BINARY

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 support The compiler and the object programs it produces can be run under VSE/ESA.

What is PERFORM ?
The PERFORM statement is a PROCEDURE DIVISION statement which transfers control to one or more specified procedures and controls as specified the number of times the procedures are executed. After execution of the specified procedures is completed (i.e., for the appropriate number of times or until some specified condition is met), control is transferred to the next executable statement following the PERFORM statement. There are 5 types of PERFORM statements: a) Basic PERFORM b) PERFORM TIMES c) PERFORM UNTIL d) PERFORM VARYING e) IN-LINE PERFORM

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

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

How many bytes does a s9(4)comp-3 field occupy ?
3Bytes (formula : n/2 + 1))

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.

What is the difference between Structured COBOL Programming and Object Oriented 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.

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.

Can JUSTIFIED be used for all the data types ?
No, it can be used only with alphabetic and alphanumeric data types.

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.

What will happen if you code GO BACK instead of STOP RUN in a stand-alone COBOL program i.e. a program which is not calling any other program ?
Both give the same results when a program is not calling any other program. GO BACK will give the control to the system even though it is a single program.

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.

You are writing report program with 4 levels of totals: city, state, region and country. The codes being used can be the same over the different levels, meaning a city code of 01 can be in any number of states, and the same applies to state and region code so how do you do your checking for breaks and how do you do add to each level ?
Always compare on the highest-level first, because if you have a break at a highest level, each level beneath it must also break. Add to the lowest level for each record but add to the higher level only on a break.

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.

Why occurs can not be used in 01 level ?
Because, Occurs clause is there to repeat fields with same format, not the records.

What is report-item ?
A Report-Item Is A Field To Be Printed That Contains Edit Symbols

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.

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.

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

How do we get current date from system with century ?
By using Intrinsic function, FUNCTION CURRENT-DATE

What is the maximum length of a field you can define using COMP-3 ?
10 Bytes (S9(18) COMP-3).

Why do we code s9 (4) comp , In spite 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.

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.

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

No comments:

Post a Comment