COBOL Interview Questions with Answers.
FAQs helpful for clearing any COBOL Job Interview.
What does passing BY CONTENT mean?Answer : The calling program passes only the contents of the literal, or identifier. With a CALL . . . BY CONTENT, the called program cannot change the value of the literal or identifier in the calling program, even if it modifies the variable in which it received the literal or identifier.
What does passing BY VALUE mean?Answer : The calling program or method is passing the value of the literal, or identifier, not a reference to the sending data item. The called program or invoked method can change the parameter in the called program or invoked method. However, because the subprogram or method has access only to a temporary copy of the sending data item, those changes do not affect the argument in the calling program. Use By value, If you want to pass data to C program. Parameters must be of certain data type.
What is the default, passing BY REFERENCE or passing BY CONTENT or passing BY VALUE?
Answer : Passing by reference (the caller and the called share the same memory).
Where do you define your data in a program if the data is passed to the program from a Caller program?Answer : Linkage Section
Define the structure of a COBOL subroutine.Answer : The PROCEDURE DIVISION header must have a using a phrase, if the data needs to be passed to the program. The operands of the USING phrase must be defined in the LINKAGE SECTION as 01-level or 77-level entries. No VALUE clause is allowed unless the data defined is a condition name.
If the program needs to be returned to the CALLER, use EXIT PROGRAM statement at the end of the program. GOBACK is an alternative, but is nonstandard.
What is difference between next sentence and continueAnswer : NEXT SENTENCE gives control to the verb following the next period. CONTINUE gives control to the next verb after the explicit scope terminator. (This is not one of COBOL II's finer implementations). It's safest to use CONTINUE rather than NEXT SENTENCE in COBOL II. CONTINUE is like a null statement (do nothing) , while NEXT SENTENCE transfers control to the next sentence (!!) (A sentence is terminated by a period). Check out by writing the following code example, one if sentence followed by 3 display statements: If 1 > 0 then next sentence end if display 'line 1' display 'line 2'. display 'line 3'. *** Note- there is a dot (.) only at the end of the last 2 statements, see the effect by replacing Next Sentence with Continue ***
What is the difference between Structured Cobol Programming and Object Oriented COBOL programming?Answer : Structured programming is a Logical way of programming using which you divide the functionality's into modules and code logically. OOP is a Natural way of programming in which you identify the objects, first then write functions and 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.
PIC S9(4)COMP is used in spite of COMP-3 which occupies less space why?Answer : S9(4) COMP uses only 2 bytes. 9(4) COMP-3 uses 3 bytes. 3 bytes are more than 2 bytes. Hence COMP is preferred over COMP-3 in this case.
How many number of bytes and digits are involved in S9(10) COMP?Answer : 8 bytes (double word) and 10 digits. Up to 9(9) comp use full word, up to 9(18) comp needs double word.
How many numbers of decimal digits are possible, when the amount of storage allocated for a USAGE COMP item is a) half word b) full word c) double word?Answer : 2 bytes (halfword) for 1-4 Digits 4 bytes (fullword) for 5-9
8 bytes (doubleword) for 10-18
What is a scope terminator? Give examples.Answer : Scope terminator is used to mark the end of a verb e.g. EVALUATE, END-EVALUATE , IF, END-IF.
How many dimensions are allowed for a table?Answer : 7
How many subscripts or indexes are allowed for an OCCURS clause?Answer : 7
Why cannot Occurs be used in 01 level?Answer : Because, Occurs clause is there to repeat fields with the same format, but not the records.
Can a REDEFINES clause be used along with an OCCURS clause?Answer : Yes, if the REDEFINES clause is subordinate to OCCURS clause.
Can you specify PIC clause and a VALUE with an OCCURS clause? Will the following code compile without errors?
01 WS-TABLE.
03 WS-TABLE-EL OCCURS 5 TIMES PIC X(1) VALUE SPACES.
Answer : Yes, the code will compile without any errors.
What would be the output, when the following code is executed?
01 WS-TABLE.
03 WS-TABLE-EL OCCURS 5 TIMES PIC X(1) VALUE 'AAAAA'.
Answer : It cannot be executed because the code will compile with error ' "VALUE" literal "'AAAA'" exceeded the length specified in the "PICTURE" definition'.
01 WS-TABLE.03 WS-TABLE-EL OCCURS 5 TIMES PIC X(1) VALUE 'A'.
03 WS-EX REDEFINES WS-TABLE-EL PIC X(5). What can you expect?
Answer : Compile error. Direct Redefinition of OCCURS clause is not allowed.
Related Posts
No comments :