Program Communication Statements Interview Questions
What is program communication statements?
Program communication statements manage interactions between program components, different programs, or external entities.
What are the program communication statements?
The program communication statements are –
- CALL Statement
- Cancel Statement
- STOP RUN Statement
- EXIT PROGRAM Statement
- GOBACK Statement
- GO TO Statement
What is the main program or calling program?
Main program or calling program calls the sub program to execute a specific task.
What is the sub program or called program?
Sub program or called program that is called by some program to perform a specific task.
CALL Statement -
What is the use of CALL statement?
A CALL statement is used to invoke a subprogram to complete a task.
What are the ways of calling the subprogram?
CALLs are two types based on how the subprogram is called from main program -
- Static call
- Dynamic call
What is the static calling?
CALL statement with SUBPROG name in quotes makes the call as STATIC CALL.
What is the dynamic calling?
A CALL statement with a variable that contains the SUBPROG name makes the call as DYNAMIC CALL.
What are different ways to pass the parameters from Main program to sub program?
There are two ways of passing parameters from MAINPROG to SUBPROG, and those are -
- BY REFERENCE
- BY VALUE
- BY CONTENT
CANCEL Statement -
What is the Cancel statement?
CANCEL is used to release the resources associated with a previously called subprogram.
STOP RUN -
What is the use of STOP RUN in COBOL program?
STOP RUN is used to terminate the execution of a program. Once it is executed, control returns to the operating system.
EXIT PROGRAM -
What is the use of EXIT PROGRAM in COBOL program?
EXIT PROGRAM marks the end of a subprogram (called program) processing and returns control to the main program (calling program).
GOBACK -
What is the use of GOBACK in COBOL program?
GOBACK defines the logical end of a program and gives the control back from where it was received.
GO TO -
What is the use of the GO TO statement in COBOL?
GO TO transfers control to another part of the program, allowing the program to "jump" to a different paragraph or section.
How many types of GO TO statements?
Other ways of using the GO TO statement are -
- Unconditional GO TO
- Conditional GO TO
Common Questions -
What is the contrast between main(calling) and sub(called) programs in programming?
Main(calling) program | Sub(called) program |
---|---|
Main program or calling program calls the sub program to execute a specific task | Sub program or called program that is called by some program to perform a specific task |
CALL Statement should be used | CALL Statement shouldnot used |
Uses STOP RUN or GOBACK | Uses GOBACK or EXIT PROGRAM |
Frequently Asked Questions -
What is the difference between a called and calling program?
State the difference between GOBACK and STOP RUN?
What will happen if you code GO BACK instead of STOP RUN in a stand-alone COBOL program i.e. a program which is not calling any other program?
Explain the difference between STOP RUN, GOBACK and EXIT PROGRAM in COBOL?
What is the difference between static call and dynamic call?What is significance of Cancel Statement?
Where the STOP RUN is coded?
Where the EXIT PROGRAM is coded?
Where the GOBACK is coded?