COBOL or Common Business Oriented Language is an English like compiled programming language used mainly for business. A COBOL program runs on any Main Frame Server and is easily portable.
To ace your COBOL interview, you can go through the following 18 COBOL questions and answers.
1. What do you know about COBOL?
COBOL is the abbreviation for Common Business Oriented Language. It is among the old programming languages and is primarily used in finance, business and administrative systems and applications.
2. What are the data types that COBOL supports?
COBOL supports 3 different data types- Alphanumeric (X), Alphabetic(A) and Numeric(9).
3. What are the different divisions of a COBOL program?
The various divisions of a COBOL program are IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, DATA DIVISION and PROCEDURE DIVISION.
4. List a few features of the COBOL language
COBOL is a structured, standard programming language that can be compiled and executed on any machine. It is typically used in business applications as it can handle a large volume of data. It contains numerous debugging and testing capabilities.
5. What is meant by IS NUMERIC clause?
The IS NUMERIC clause is used to check if an item is numeric or not. The value returned will be TRUE if the item that is checked for contains only numbers whether positive or negative.
6. What are level 66 and level 88 in COBOL?
Level 66 is used in RENAMES clause and level 88 is used for condition names.
7. Differentiate between Subscript and Index.
Subscript refers to the occurrence in an array whereas Index refers to the number of bytes or displacement from the beginning of the array.
An Index can be modified only with PERFORM, SEARCH and SET commands.
The index is needed to perform SEARCH or SEARCH ALL in a Table.
8. Differentiate between SEARCH and SEARCH ALL.
SEARCH command in COBOL is used for serial search while SEARCH ALL is used to binary search where the table or array must be sorted using ASCENDING or DESCENDING key.
9. What is the difference between performing a SECTION and performing a PARAGRAPH?
When you perform a SECTION, all paragraphs under the section will be performed. But if you are performing a paragraph, only the particular paragraph will be performed.
10. What are the modes of File opening in COBOL?
The modes of opening a file in COBOL are OUTPUT, INPUT, I/O and EXTEND.
What is the extreme size of a mimetic field that can be defined in COBOL?
The maximum size of a numeric field that can be defined in COBOL is PIC 9(18).
11. What is the difference between CONTINUE and NEXT SENTENCE commands?
CONTINUE command is similar to a null command that brings about execution while NEXT SENTENCE command handovers control to the subsequent sentence.
12. What are the various applications of the OPEN mode in COBOL?
The OPEN mode can be used for operations such as INPUT, OUTPUT, INPUT-OUTPUT and EXTEND.
13. Explain the terms Static Linking and Dynamic Linking.
In Static linking, the subroutine links into the calling program whereas in Dynamic linking, the key program and subroutine will remain as separate modules. Static linking and Dynamic linking can be attained by link edit options- DYNAM or NODYNAM.
14. Explain the function of EVALUATE statement in COBOL.
EVALUATE statement does the same job of a CASE statement or a nested-IF statement. The main difference between EVALUATE and nested-IF is that “break” is not needed for the former and the control leaves the EVALUATE statement once a match is found.
15. Explain the difference between PERFORM …WITH TEST AFTER and PERFORM…WITH TEST BEFORE.
In TEST BEFORE option, the condition will be tested at the beginning of each execution of the PERFORM block.
In TEST AFTER option, the condition will be tested at the end of the PERFORM block.
16. 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
17. What kinds of errors are caught by the ON SIZE ERROR OPTION?
The following errors are trapped by the ON SIZE ERROR option:
Fixed point overflow
Number zero raised to power zero
Divide by zero
Number zero raised to power negative number
A negative number raised to the power of a fraction.
18. Differentiate between structured COBOL program and Object Oriented COBOL Program.
Structured programming is the logical way of writing a program where functions are divided into modules and tackled logically.
Object oriented programs are those where you write the methods and functions around the Object that is identified.
COBOL is a structured and a very user friendly programming language. It is one of the oldest programming language and the functionality it provides for big administrative systems cannot be easily replaced.