COBOL Interview Questions Answers 6

11/05/2009 No Comment

COBOL Question Answers.

Mainframe COBOL Questions and Answers.

Why do you use the EVALUATE statement in VSAM?
Answer : In VSAM, Evaluate statement is like a case statement and it can be used to replace nested Ifs. The main difference between EVALUATE and case is that no ‘break’ is required for EVALUATE and hence control will come out of the EVALUATE as soon as one match is found in the program.

Explain what is the difference between PERFORM ... WITH TEST AFTER and PERFORM ... WITH TEST BEFORE?
Answer : If the TEST BEFORE is specified, then the condition is tested right at the very beginning of each repeated execution of the specified PERFORM range.
If TEST AFTER is specified in a COBOL program, the condition is tested only at the end of the each repeated execution of the PERFORM range.
When we use TEST AFTER, the range is executed at least once.

Can you tell me which is the default, TEST BEFORE or TEST AFTER for a PERFORM statement.

Answer : The default is TEST BEFORE

Tell us how you code an in-line PERFORM in COBOL?

Answer : The coding is PERFORM ... ... END-PERFORM.

Under what circumstances would you use in-line perform in COBOL?

Answer : Whenever the body of the perform will not be used in other paragraphs. If the body of the perform is a generic type of code, it would be better to put the code in a separate Para and then use PERFORM paraname rather than in-line perform.

When you use EVALUTE statement, is the order of the WHEN clauses significant?

Answer : Yes it is important, evaluation of the when clause proceeds from top to bottom

Explain how can you come out of an EVALUATE statement?

Answer : After the execution of one of the when clauses, the control is automatically passed on to the next sentence after the EVALUATE statement. There is no need of any extra code for this.

What should be the default value for an INITIALIZE and what is the keyword that allows for an override of the default.

Answer : INITIALIZE sets spaces to alphabetic and alphanumeric fields. It initialize and sets Zeroes to numeric fields. FILLER, OCCURS DEPENDING ON items are left untouched. The REPLACING option can be used to override these defaults.

What is the significance of a delimiter in a STRING? 
Answer : A delimiter in STRING causes a sending field to be ended and another to be started.

What do you mean by LENGTH in COBOL II?

Answer : In COBOL II, LENGTH acts like a special register to tell the length of a group or an elementary item.

What is the function of a delimiter in UNSTRING in COBOL?

Answer : A delimiter when encountered in the sending field causes the current receiving field to be switched to the next one indicated.

What kind of error is trapped by ON SIZE ERROR option in COBOL?

Answer : Fixed-point overflow. Zero raised to the zero power.
Division by 0. Zero raised to a negative number.
A negative number raised to a fractional power.

What is the main purpose of the REPLACING option of a copy statement?

Answer : REPLACING allows for the same copy to be used more than once in the same code by modifying/changing the replace value.COPY xxx REPLACING BY .

When does a scope terminator become mandatory in COBOL?

Answer : Scope terminators become mandatory for in-line PERFORMS and EVALUATE statements. For the sake of readability, it's advisable coding practice to always make scope terminators explicit.

Can you tell me if you can use REDEFINES clause in the FILE SECTION?

Answer : No, we cannot use REDEFINES clause.
Related Posts


No comments :

 

Aired | The content is copyrighted and may not be reproduced on other websites. | Copyright © 2009-2016 | All Rights Reserved 2016

Contact Us | About Us | Privacy Policy and Disclaimer