Compiler Directive Statements Interview Questions


What is the compiler-directive statement?

Compiler-directing Statements (often called "directives") provide instructions to the COBOL compiler about how the program should compile and produce the desired object code.

What are the different compiler options?

The compiler-directive statements used in the COBOL program are -

  • COPY
  • EXIT
  • EJECT
  • SKIP
  • BASIS
  • CALLINTERFACE
  • DELETE
  • ENTER
  • INSERT
  • PROCESS (CBL)
  • REPLACE
  • SERVICE LABEL
  • TITLE
  • USE
  • SSRANGE
  • NOSSRANGE

What is SSRANGE, and NOSSRANGE?

SSRANGE is used to locate a subscript that is out of range and manage array overflow.
NOSSRANGE ensures no run-time error if a subscript or index is out of range.

What care has to be taken to force program to execute above 16 Meg Line?

Make sure that link option is AMODE=31 and RMODE=ANY. Compile option should never have SIZE (MAX).

Explain the terminologies - AMODE(24), AMODE(31), RMODE(24), and RMODE(ANY)?

  • AMODE(24) - 24 bit addressing. AMODE(31) - 31 bit addressing.
  • AMODE(ANY) - Either 24 bit or 31 bit addressing depending on RMODE.
  • RMODE(24) - Resides in virtual storage below 16 Meg line. Use this for 31 bit programs that call 24 bit programs. (OS/VS Cobol pgms use 24 bit addresses only).
  • RMODE(ANY) - Can reside above or below 16 Meg line.

COPY Statement -

What is a COBOL copybook?

Copybook is a peice of code which can contain file structure or PROCEDURE DIVISION code (paragraphs or sections).

What are the benefits of using copybook?

COPY statement is useful when -

  • The file structure is too big to include directly in the program.
  • We can easily manage changes by saving the file structures separately and using them in multiple programs.
  • One copybook can create multiple file structures using REPALCING phrases.

What is the COPY statement?

COPY statement includes predefined copybooks (usually file record structures) from the library that is outside of the program.

You must COPY a copybook multiple times in your program. How will you do it?

Using COPY..REPLACING

What does the REPLACING option do in a COPY statement?

It replace the source string with the target string.

EXIT Statement -

What does EXIT do?

EXIT statement is a "do-nothing" statement mainly used for readability and structure, giving a logical end-point for a section or paragraph.

Define one use Exit?

Indicate the end of a paragraph that may be used as a logical exit or termination point in the program.

EJECT Statement -

What does EJECT do?

EJECT statement specifies that the next source statement after it should be printed as the first statement of the next page while printing.

SKIP Statement -

What does SKIP do?

SKIP1, SKIP2, or SKIP3 statements specify the number of blank lines that should replace the SKIP statement while listing the COBOL source code.

Common Questions -

How is INCLUDE different from COPY?

INCLUDECOPY
Used to include the PROCEDURE DIVISION copybooks Used to include the structures declared in DATA DIVISION
Should code in PROCEDURE DIVISION Should code in DATA DIVISION

Frequently Asked Questions -

How is SSRANGE different from NOSSRANGE?

Explain the advantage of using a copy book in programming?
What is the use of the COPY statement in COBOL, and how can it be used to modularize and reuse code?
What is the use of the COPYBOOK statement in COBOL, and how can it be used to include external files and libraries?

What use does a copy statement’s REPLACING option serve?
What is the importance of using REPLACING option in a COPY statement?

What is the use of the EXIT statement in COBOL, and how can it be used to terminate programs and subprograms?