COBOL interview question set 2/COBOL Interview Questions and Answers for Freshers & Experienced

How do we get current date from system with century?

By using Intrinsic function, FUNCTION CURRENT-DATE

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.

Why occurs can not be used in 01 level ?

Because, Occurs clause is there to repeat fields with same format, not the records.

How Do You Define A Variable Of Comp-1 And Comp-2?

There is no picture clause to be given. Example 01 WS-VAR USAGE COMP-1.

How Is Sign Stored In A Comp Field?


It is stored in the most significant bit. Bit is ON if -ve, OFF if +ve.

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.

What is a report item?

A report item is a field to be printed which has Edit Symbols.

What are literals?

A literal is a data item which consists value by itself. It cannot be referred by a name. They are constant data items. There are two types of literals:

String / Alphanumeric Literals
Numeric Literals

How many bytes S(8) comp field occupy and its maximum value?

S(8) can store 4 bytes and the highest value is 99999999.

Which of the Search verbs is equivalent to PERFORM…VARYING?

The serial SEARCH verb is equivalent to the Perform-Varying statement, and it is nothing but search without ALL.

Why does the file always need to be opened in I-O mode for REWRITE purposes?

Even before the REWRITE is performed, the record must be opened and read from the file. For the same purpose, the file must be opened in I-O mode for REWRITE functionality.

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.

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 programs working storage. You SET an index to a value and SET it UP BY value and DOWN BY value.

What guidelines should be followed to write a structured Cobol prg'm?

1) use 'evaluate' stmt for constructing cases.

2) use scope terminators for nesting.

3) use in line perform stmt for writing 'do ' constructions.

4) use test before and test after in the perform stmt for writing do-while constructions.

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 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 sorting order for SEARCH ALL?

Searching orders for SEARCH ALL can be either ASCENDING or DESCENDING. ASCENDING is the default one. If you want the search to be done on an array sorted in descending order, then while defining the array, you should give DESCENDING KEY clause. (You must load the table in the specified order).

What is the use of INTIALIZE verb in Cobol?

INITIALIZE verb initializes the values in a data item to the default value. Numeric edited items are set to zero, alphabetic fields and alphanumeric edited items are set to spaces. FILLERS, OCCURS DEPENDING ON items are left untouched.

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

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.

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.

When is a scope terminator mandatory?

Scope terminators are mandatory for in-line PERFORMS and EVALUATE statements. Make scope terminator as explicit for good coding standards.

What are the different rules of SORT operation?

SORT can be performed when

1. Input and Output files must remain closed
2. Working file must have a select clause
3. Input and Output files have FD entries
4. Work file should have short description in File Section

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.

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

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.

What is the difference between a binary search and a sequential search?

In a binary search, the table element key values will be in ascending or descending sequence. The table is ‘halved'(Divided into two) 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 the elements do not have to be in a specific sequence.

The binary search is much faster for more tables, while sequential Search works well with lesser ones. SEARCH ALL is used for binary search; SEARCH for sequential search.

What is binary search?

First, we have to compare the item to be searched with the item at the center.

If it matches, it is good to go with the value else repeat the process with the left half or the right half depending on where the item lies.

How to find out the current date from a system with the century?

To find out the current date with the century, use an Intrinsic function called Function Current Date.

What guidelines should be followed to write a structured COBOL program?

Following guidelines to be following while writing Cobol program:

>> Use ‘EVALUATE’ statement for constructing cases.
>> Use scope terminators for nesting.
>> Use in-line Perform statement for writing ‘do’ constructions.
>> Use Test Before and Test After in the Perform statement while writing Do-While statements.

What are the guidelines one must follow while writing a structured COBOL program?

One must follow certain guidelines while writing COBOL. They are mentioned below:

Using the ‘EVALUATE’ statement for constructing cases

Using scope terminators for nesting

Using in-line Perform statement for writing ‘do’ constructions

Using Test Before and Test After in the Perform statement while writing Do-While statements

What is the meaning of Pic 9v99?

Pic 9v99 refers to a three-position numeric field with an implied or assumed decimal point after the first position.

Here, v stands for an implied decimal point.

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 function of REPLACING in a COPY statement?

REPLACING allows for the same copy to be repeated more than once in the same code just by replacing the value.
Syntax: COPY REPLACING BY

Why occurs cannot be used in 01 level ?

Because, Occurs clause is there to repeat fields with same format, not the records.

Can JUSTIFIED be used for all the data types?

No, it can be used only with alphabetic and alphanumeric data types.

Give some advantages of REDEFINES clause.

You can REDEFINE a Variable from one PICTURE class to another PICTURE class by using the same memory location. By REDEFINES we can INITIALIZE the variable in WORKING-STORAGE Section itself. We can REDEFINE a Single Variable into so many sub-variables. (This facility is very useful in solving Y2K Problem.)

What is an in line PERFORM? When would you use it? Anything else 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.

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

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.

What is the difference between COMP & COMP-3 ?

COMP is a binary storage format while COMP-3 is packed decimal format.

How is sign stored in Packed Decimal fields and Zoned Decimal fields?

Packed Decimal fields: Sign is stored as a hex value in the last nibble (4 bits ) of the storage.

Zoned Decimal fields: As a default, sign is over punched with the numeric value stored in the last bite

What is a scope terminator? Give examples.

Scope terminator is used to mark the end of a verb e.g. EVALUATE, END-EVALUATE; IF, END-IF.

Define an in-line PERFORM?

Through an IN-LINE PERFORM statement, the routine is being performed to be nested within the perform statement instead of being a separate paragraph.

While the PERFORM and END-PERFORM statements are used to block the COBOL statements between them, in line PERFORM work as long as there are no internal GO TOs, not even to an exit.

How can you define LOCAL-STORAGE SECTION?

Each time the program is called, Local-Storage is allocated, and then it is deallocated when the program stops via an EXIT PROGRAM, GOBACK, or STOP RUN. It is defined in the DATA DIVISION after WORKING-STORAGE SECTION.

What are the differences between Structured COBOL Programming and Object-Oriented COBOL programming?

Structured programming can be defined as a logical way of programming. In this, the functionalities are divided into modules and help the programmer to write the code logically.

Object-Oriented COBOL is a natural way of programming. In this, programmers identify the objects and then write functions and procedures around that object.

What is the role played by the ACCEPT verb?

The ACCEPT verb is a basic statement used in COBOL for retrieving data like time, date and day from the user or program. In the educational data, ACCEPT verb and DISPLAY are used to receive information for a student record.

Search
R4R Team
R4R provides COBOL Freshers questions and answers (COBOL Interview Questions and Answers) .The questions on R4R.in website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,COBOL interview question set 2,COBOL Freshers & Experienced Interview Questions and Answers,COBOL Objetive choice questions and answers,COBOL Multiple choice questions and answers,COBOL objective, COBOL questions , COBOL answers,COBOL MCQs questions and answers Java, C ,C++, ASP, ASP.net C# ,Struts ,Questions & Answer, Struts2, Ajax, Hibernate, Swing ,JSP , Servlet, J2EE ,Core Java ,Stping, VC++, HTML, DHTML, JAVASCRIPT, VB ,CSS, interview ,questions, and answers, for,experienced, and fresher R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for COBOL fresher interview questions ,COBOL Experienced interview questions,COBOL fresher interview questions and answers ,COBOL Experienced interview questions and answers,tricky COBOL queries for interview pdf,complex COBOL for practice with answers,COBOL for practice with answers You can search job and get offer latters by studing r4r.in .learn in easy ways .