COBOL Realtime (Scenario based) Interview Questions (1 - 10)
1. What are the differences between OS COBOL and VS COBOL II?
OS COBOL | VS COBOL II |
---|---|
Runs in 24-bit addressing mode | 31-bit addressing mode introduced. Runs either in 24-bit or 31-bit addressing modes |
Supports Report Writer | Does not support Report Writer |
USAGE IS POINTER is not supported | USAGE IS POINTER is supported |
Reference modification is not supported | Reference modification is supported |
EVALUATE is not supported | EVALUATE is supported |
Scope terminators are not supported | Scope terminators are introduced |
Follows ANSI 74 standards | ANSI 85 standards are followed |
Calls between programs are not supported under CICS | Calls between programs are supported under CICS |
2. What is the difference between VS COBOL and enterprise COBOL?
VS COBOL | Enterprise COBOL |
---|---|
It supported the 68 COBOL Standard and the 74 COBOL Standard | It supports the 85 COBOL Standard |
Undocumented OS/VS COBOL extensions supported | Undocumented OS/VS COBOL extensions not supported |
3. Assume you are writing a program. What are the divisions, sections, paragraphs, sentenses you need to code to get the program successfully compiled?
Below are mandatory in COBOL programs -
- IDENTIFICATION DIVISION, PROGRAM-ID paragraph
- PROCEDURE DIVISION
4. There is no debugging tools available in the project. What are the things you do to see the program execution flow or certain paragraph execution?
We can approach this in two ways -
- Add display statements to the program wherever necessary.
- If debugging mode is implemented in the program, enable the debugging statements marked with 'D' in the 7th column by
uncommenting the line:
SOURCE-COMPUTER IBM370 WITH DEBUGGING MODE.
If the program runs in a batch environment, the output will be available in the job's SYSOUT. If it operates in an online environment, the output can be found in the regional job.
5. Write some sample code to enable DEBUGGING MODE in the program?
If SOURCE-COMPUTER..WITH DEBUGGING MODE is coded, the program recognizes the statements with 'D' in the 7th column as part of the code. This enables the debugging mode in the program.
Examples - Example to enable DEBUGGING MODE.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM3278 WITH DEBUGGING MODE.
PROCEDURE DIVISION.
D DISPLAY "DISPLAYING DEBUGGING LINE".
DISPLAY "DISPLAYING NORMAL LINE".
Output -
DISPLAYING DEBUGGING LINE DISPLAYING NORMAL LINE
6. How can you code the following file formats in the COBOL program?
- Fixed Block File
- Fixed Unblock File
- Variable Block File
- Variable Unblock File
- Printer File
Fixed Block File - Fixed-length records stored in fixed-size blocks. Each block contains a fixed number of records.
SELECT FILE-FB ASSIGN TO INPUTFL
ORGANIZATION IS SEQUENTIAL
RECORDING MODE IS F
BLOCK CONTAINS 10 RECORDS.
Fixed Unblock File - Fixed-length records, but not grouped into blocks.
SELECT FILE-FB ASSIGN TO INPUTFL
ORGANIZATION IS SEQUENTIAL
RECORDING MODE IS F.
Variable Block File - Variable-length records stored in blocks. Each block can contain different record sizes.
SELECT FILE-FB ASSIGN TO INPUTFL
ORGANIZATION IS SEQUENTIAL
RECORDING MODE IS V
BLOCK CONTAINS 10 RECORDS.
Variable Block File - Variable-length records, not grouped into blocks.
SELECT FILE-FB ASSIGN TO INPUTFL
ORGANIZATION IS SEQUENTIAL
RECORDING MODE IS V
BLOCK CONTAINS 10 RECORDS.
Printer File - Used for printing output. Data is formatted as lines, often with carriage control characters.
SELECT PRINT-FILE ASSIGN TO PRINTER
ORGANIZATION IS SEQUENTIAL
RECORDING MODE IS F.
7. I have a file declared in the program. How can we identify the file type by just looking at the code?
The file type can be identified by checking the SELECT clause and ORGANIZATION keyword in the ENVIRONMENT DIVISION.
File Type | Identification in Code |
---|---|
Sequential File |
|
Sequential File (ESDS) |
|
Indexed File (KSDS) |
|
Relative File (RRDS) |
|
8. How many ways you can initialize a variable?
The initializing variable can be done in three ways -
- Using VALUE clause at the time of declaration.
- Using INITIALIZE statement in PROCEDURE DIVISION.
- Using MOVE statement in the PROCEDURE DIVISION.
9. What is the section that is used to receive the data from outside of the program?
LINKAGE SECTION is used to receive the data from outside the program.
10. How many ways can we receive the data from outside of the program?
A COBOL program can receive data from external sources in five main ways:
- Using ACCEPT Statement - Receives input from the keyboard, system date, or runtime parameters.
- Using JCL PARM= (Batch Processing) - Receives parameters from JCL job execution. ACCEPT statement receives this information.
- Using CALL USING (Subprograms) – Receives data from another COBOL program via LINKAGE SECTION.
- Using READ (From Files) – Receives data from sequential, indexed, or relative files.
- Using EXEC SQL (Database Fetching) – Retrieves data from DB2 or other relational databases.