Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction to COBOL
2.
Cobol Interview Questions for Freshers
2.1.
1. What do you know about Cobol?
2.2.
2. What is COBOL in ETL?
2.3.
3. Is COBOL still in use or still valuable to learn?
2.4.
4. How many datatypes are there in COBOL?
2.5.
5. What is Z in COBOL?
2.6.
6. What is DB & CR in COBOL?
2.7.
7. What is FD and SD in COBOL?
2.8.
8. What are data types in COBOL?
2.9.
9. What is 01 to 49 level number in COBOL?
2.10.
10. What distinguishes an index from a subscript?
2.11.
11. What distinguishes a section from a paragraph?
2.12.
12. What distinguishes NEXT SENTENCE from CONTINUE?
2.13.
13. What divisions are there in a COBOL program?
2.14.
14. What function does the verb ACCEPT serve?
2.15.
15. Explain Static and dynamic linking.
3.
Cobol Interview Questions for Intermediate
3.1.
16. How do I merge two files in COBOL?
3.2.
17. What is included in the change history for every given issue?
3.3.
18. Explain the usage of EVALUATE statement.
3.4.
19. What does the phrase "Pic 9v99" mean?
3.5.
20. What is the relevance of a copy statement REPLACING option?
3.6.
21. What are the distinctions between Structured and Object-Oriented COBOL programming?
3.7.
22. What is the significance of including the REPLACING option in a COPY statement?
3.8.
23. How is SSRANGE different from NOSSRANGE?
3.9.
24. What is file handling in COBOL?
3.10.
25. How do I sort two files in COBOL?
3.11.
27. What happens during the INPUT and OUTPUT PROCEDURE?
3.12.
28. Why is the LINKAGE SECTION required?
4.
Advanced COBOL Interview Questions
4.1.
29. Why not define the OCCURS clause at the 01 levels?
4.2.
30. What distinguishes the CALL command from the LINK command?
4.3.
31. What is the significance of the INITIALIZE verb?
4.4.
32. Why is the file being opened in I-O mode when it is being used for REWRITE?
4.5.
33. Why is S9(4) COMP required when Comp-3 would take up less space?
4.6.
34. Is stop run mandatory in COBOL?
4.7.
35. What is the definition of LOCAL-STORAGE SECTION?
4.8.
36. What is the difference between INPUT PROCEDURE and OUTPUT PROCEDURE?
4.9.
37. What is the function of the LINKAGE SECTION?
4.10.
38. Define the START statement's access modes.
4.11.
39. What are the distinctions between Global Variables and External Variables?
5.
Frequently Asked Questions
5.1.
What are 66-77 and 88 levels in COBOL?
5.2.
Is stop run mandatory in COBOL?
5.3.
What is the size limit of linkage section in COBOL?
5.4.
What is the maximum size of a numeric field we can define in COBOL?
6.
Conclusion
Last Updated: Jun 3, 2024
Easy

Cobol Interview Questions

Author Shiva
0 upvote

Introduction to COBOL

COBOL stands for Common Business Oriented Language. It is procedural, object-oriented, and imperative. A computer program called a compiler converts other computer programs written in high-level (source) languages into machine code, which the computer can understand. Data is input into a file or database, processed, and produced via COBOL. In a nutshell, COBOL receives data, computes it, and then produces the results.

Here is a list of top Cobol Interview questions. These Cobol interview questions are categorized into difficulty levels easy, medium, and hard.

Top Cobol Interview Questions and Answers (2023)

Cobol Interview Questions for Freshers

Here are some introductory level Cobol interview questions that are frequently asked:

1. What do you know about Cobol?

COBOL is one of the oldest programming languages. It stands for Common Business Oriented Language and is mainly used for business verticals like government, banking, and administrative systems. It concentrates on resolving challenging commercial issues.

2. What is COBOL in ETL?

COBOL (Common commercial-Oriented Language) is primarily employed for commercial applications. Because it is effective at processing huge volumes of data, it is a common language for ETL (extract, transform, and load) procedures.

Data can be extracted using COBOL from many different sources, such as relational databases, flat files, and legacy systems. The data can then be transformed such that it complies with the destination system's criteria. The converted data can then be loaded into the target system through COBOL.

3. Is COBOL still in use or still valuable to learn?

Yes, COBOL is still valuable to learn.  Even though the language is almost 60 years old, there has recently been an increase in demand because of the needs of some governmental organizations.

4. How many datatypes are there in COBOL?

There are 3 datatypes in COBOL: Numeric, Alphabetic, and Alpha-Numeric.

5. What is Z in COBOL?

"Z" is frequently used in COBOL as a format code for numeric data items. The acronym is "Zero Suppression." Leading zeros should not be displayed when showing a numeric data item when "Z" is specified in the PICTURE clause. For instance, using "Z" format code to show a numeric variable with a PICTURE clause of "9999" and a value of 0075 would display "75" without leading zeros.

6. What is DB & CR in COBOL?

In COBOL, "DB" stands for "Debit" and "CR" for "Credit." In financial applications, these are frequently used as prefixes for data objects that reflect monetary amounts. While credit quantities signify money being added or received, debit amounts signify money being taken out or spent. For instance, in a financial system, you might utilise variables like "DB-AMOUNT" and "CR-AMOUNT" to keep track of debit and credit transactions.

Must Recommended Topic, procedure call in compiler design

7. What is FD and SD in COBOL?

The COBOL statement FD (File Description) is used to specify the details of a file that the programme will read from or write to. The name of the file, the record structure, the access mode (such as sequential or random), and other file parameters are all specified.

SD (Sort Description): In COBOL, SD is used to define the properties of a merge or sort file. It specifies information such as the file name, record structure, and sort keys that will be applied during operations like sorting or merging.

8. What are data types in COBOL?

To define different kinds of data items, COBOL offers a variety of data types. Some typical COBOL data types are as follows:

Data types like INTEGER, COMP (binary), COMP-3 (packed decimal), and others are used for numerical data.

  • Text data that is alphabetized comprises kinds like CHAR and STRING.
  • Alphanumeric characters combine both alphabetic and numeric characters.
  • Booleans are used for yes/no or true/false values; typically defined using "PIC X" or "PIC 9" with appropriate values.
  • To work with date and time values we use Date and Time data types. COBOL offers data types like DATE and TIME.
  • Group and Nested Data: Using the GROUP and REDEFINES clauses, COBOL enables you to group related data elements. This aids in the organisation of intricate data structures.

9. What is 01 to 49 level number in COBOL?

Levels 01 to 49 in COBOL are used to specify data structures and data objects. These levels show how the data pieces are nested or arranged in a hierarchy. Here is a general summary:

The top level, Level 01, is used to describe the primary record or data structure.
Levels 02 to 49: These levels are used to specify minor data items within the primary record. The nesting level is indicated by the level numbers. Level 02 items, for instance, are below level 01 items, level 03 items are beneath level 02 items, and so on.
In a COBOL programme, these levels aid in data organisation and structuring, making it simpler to work with complex data structures.

10. What distinguishes an index from a subscript?

Although an array's Subscript is known as its occurrence, an index describes the distance from the array's start. Only the commands PERFORM, SEARCH, and SET can be used to change an index.

11. What distinguishes a section from a paragraph?

There will be paragraphs that are a part of the section that has not yet been completed. At the same time, there will only be one paragraph to perform in the event of a paragraph.

12. What distinguishes NEXT SENTENCE from CONTINUE?

Control is passed to the following sentence with the word NEXT SENTENCE. CONTINUE continues execution and behaves like a null statement.

13. What divisions are there in a COBOL program?

The average COBOL program has four divisions. Identification, environment, data, and process are what we refer to as these. The identification section is the most crucial one because it defines the program. Configuration and input-output make up the two sections of the environment division. It establishes the program's environment.

14. What function does the verb ACCEPT serve?

The word ACCEPT is a fundamental statement in COBOL that is used to get information like time, date, and day from the user or program. When receiving information for a student record in educational data, the verb ACCEPT, and the word DISPLAY is employed.

15. Explain Static and dynamic linking.

In static linking, subroutine links are invoked by the calling program. The main program and the subroutine can both live as different modules when using dynamic linking. Selecting the DYNAM or NODYNAM link edit options will allow you to link in both dynamic and static content.

Cobol Interview Questions for Intermediate

Stepping up the game, Here are some medium-level Cobol interview questions that are frequently asked:

16. How do I merge two files in COBOL?

In COBOL, you can use the MERGE statement to combine two files. In the sequence given by the KEY clause, the MERGE statement compiles the data from two or more input files into a single output file.
The MERGE statement compares the important fields in the records by reading one record from each input file. The output file contains the record with the lowest key value. Once all of the records from the input files have been processed, the MERGE statement resumes this procedure.

17. What is included in the change history for every given issue?

The Change History section displays the activity of changing any records, including information about the individual who made the change as well as the date and time of the change.

In the event of a change in any field, the change history additionally provides information about the old and new field values.

18. Explain the usage of EVALUATE statement.

Evaluation is similar to a case statement. It can be used in the same way as Nested IFs are. There is a difference to be made between EVALUATE and case. 'break' is not utilized in EVALUATE, and the control exits the EVALUATE once a match is discovered.

19. What does the phrase "Pic 9v99" mean?

Pic 9v99 denotes a three-position numeric field with a decimal point suggested or presumed after the first position.

In this case, v represents an assumed decimal point.

20. What is the relevance of a copy statement REPLACING option?

The REPLACING option allows you to reuse the duplicate copy several times by changing the replace value in the same code.

21. What are the distinctions between Structured and Object-Oriented COBOL programming?

Structured programming is a logical approach to programming. The functionalities are split into modules, which aid the programmer in writing logical code.

Object-Oriented COBOL is a natural programming language. Programmers recognize objects and then construct functions and procedures around them.

22. What is the significance of including the REPLACING option in a COPY statement?

By changing the replace value in the same code, the REPLACING option allows the duplicate copy to be used multiple times.

23. How is SSRANGE different from NOSSRANGE?

Both are options used by the compiler for finding subscripts outside of range.

SSRANGE is used to handle an array's overflow in an organized manner. It must be explicitly given, which aids in locating the exact subscript outside of range. The NOSSRANGE, on the other hand, is employed in susceptible applications that are driven by performance. It is the default option that is used and does not need to be explicitly specified, and it does not support runtime errors when the index is out of range.

24. What is file handling in COBOL?

The process of reading from and writing to external files, such as text files, sequential files, and indexed files, from within a COBOL programme is known as file handling in COBOL. You can conduct operations on files using COBOL's set of file-related statements and clauses, including opening, closing, reading from, and writing to them. When working with data stored outside the programme, such as databases or external data sources, file handling is a crucial component of COBOL programming. 

25. How do I sort two files in COBOL?

You normally follow a step-by-step procedure within your COBOL programme to sort two files. The record structures for the two input files, Files A and B, as well as the two output files, Sorted Files A and B, must first be defined. The fields you intend to use as sorting keys should be included in these record structures. The OPEN statement will then be used to open Files A and B for reading and Sorted Files A and B for writing. Make that the access modes for each file are correctly defined. After that, you will receive records from Files A and B one at a time and store them in data structures like arrays or give them directly to a sorting function in a loop. You can pick a sorting method, such quicksort.

You keep doing this until both input files are finished. To gracefully exit the loop, be careful to handle end-of-file conditions for each incoming file.

To guarantee that data is correctly flushed and files are closed, use the shut statement to shut all input and output files after processing every record.

27. What happens during the INPUT and OUTPUT PROCEDURE?

The input file is opened in INPUT PROCEDURE, and the records in the file are read and can be edited. The papers will then be released for sorting before the file is closed. In the OUTPUT PROCEDURE, the output file is opened, the records after sorting are written in the output file, and the file is closed.

28. Why is the LINKAGE SECTION required?

It is used to transfer information from one software to another. It can also be used to transfer data from one program to another. It maps data in the working storage of the calling program.

Advanced COBOL Interview Questions

Finally time for some difficult ones, Here are some hard-level Cobol interview questions that are frequently asked:

29. Why not define the OCCURS clause at the 01 levels?

The 01 level is the record level. We may duplicate the fields within a record but not the record itself. The OCCURS clause specifies that the definition of data names is repeated. The OCCURS clause cannot be used at the 01 levels.

30. What distinguishes the CALL command from the LINK command?

The CALL instruction actually starts an external application and then returns. The LINK command is similar to CALL, except it is not part of the COBOL verb vocabulary. The LINK command is executed as a separate run unit, whereas the CALL command is implemented as a single run unit.

31. What is the significance of the INITIALIZE verb?

The INITIALIZE verb is used to set values in data items to their default values. Alphabetic and alphanumeric elements will be set to spaces, while numeric entities will be set to 0. Items such as FILLERS and OCCURS DEPENDING ON should be left alone during setup.

32. Why is the file being opened in I-O mode when it is being used for REWRITE?

When performing a file REWRITE of the record, the file must first be opened, and then the record must be read from the file. This is why the file should be opened in I-O mode at all times.

33. Why is S9(4) COMP required when Comp-3 would take up less space?

S9(4) COMP indicates that the item is a tiny integer, implying that two words of one byte each can occupy a total of two bytes. In S9(4) COMP-3, one word is equal to half a byte, so four words can occupy two bytes and the sign takes up another half byte, for a total of three bytes. When compared to COMP-3, S9(4) COMP can accommodate more.

34. Is stop run mandatory in COBOL?

In COBOL, STOP RUN is required. It closes the tasks that the programme was running and is used to give the system back control.

If you don't use STOP RUN, the programme will keep running until it either encounters an error or reaches its conclusion. Even after the programme has done processing the data, this could make it continue to operate for a long time.

It's crucial to remember that in a COBOL programme, STOP RUN is only necessary for the main programme. The EXIT PROGRAMME statement can be used by subprograms to transfer control back to the main programme.

35. What is the definition of LOCAL-STORAGE SECTION?

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

36. What is the difference between INPUT PROCEDURE and OUTPUT PROCEDURE?

The input file is opened during the INPUT PROCEDURE, and records are read and changed. These records are subsequently handed over to the sorting process. The file will then be closed.

The output file is opened during the OUTPUT PROCEDURE, the sorted record is returned to the Output record, and the record is eventually written. The file will then be closed.

37. What is the function of the LINKAGE SECTION?

The linking section is used to transfer data from one program to another or from one procedure to another. It is a program that maps data objects in the working storage of the calling program.

38. Define the START statement's access modes.

For the start statement, access modes are SEQUENTIAL or DYNAMIC.

39. What are the distinctions between Global Variables and External Variables?

Only the batch program has access to global variables, whereas external variables can be accessed by any batch program in the same system library.

Frequently Asked Questions

What are 66-77 and 88 levels in COBOL?

66 level is used for RENAMES clause to regroup fields. 77 level is for standalone fields. 88 level is used for condition names, providing a readable way to reference values.

Is stop run mandatory in COBOL?

No, STOP RUN is not mandatory in COBOL. It's used to indicate the end of the program, but other termination methods like GOBACK or EXIT PROGRAM can also be used.

What is the size limit of linkage section in COBOL?

The size limit of the Linkage Section in COBOL depends on the compiler, but it can typically handle up to 128 megabytes of data, accommodating large amounts of external data passed to the program.

What is the maximum size of a numeric field we can define in COBOL?

The maximum size of a numeric field in COBOL is 18 digits for both integer and decimal fields, depending on the compiler's limitations and the usage context within the program.

Conclusion

This article discussed Cobol Interview Questions. Preparing for a COBOL interview requires a solid understanding of its key concepts and functionalities. By familiarizing yourself with commonly asked questions and their answers, such as the usage of different levels, mandatory statements, and size limits, you can build confidence and demonstrate your proficiency. 

You can refer to other similar articles as well -  

And many more on our website.

Visit our website to read more such blogs. Make sure you enroll in the courses we provide, take mock tests, solve problems, and interview puzzles. Also, you can pay attention to interview stuff- interview experiences and an interview bundle for placement preparations.

 

Live masterclass