Chapter 26 Quiz: Inter-Language Communication
Multiple Choice
1. What is COBOL's default parameter passing mechanism?
a) BY VALUE b) BY REFERENCE c) BY CONTENT d) BY ADDRESS
2. When calling a C function that expects an int parameter, which COBOL clause should you use?
a) BY REFERENCE with PIC S9(9) COMP b) BY VALUE with PIC S9(9) COMP c) BY REFERENCE with PIC 9(9) DISPLAY d) BY VALUE with PIC S9(7)V99 COMP-3
3. COBOL strings differ from C strings because:
a) COBOL strings are null-terminated; C strings are space-padded b) COBOL strings are space-padded and fixed-length; C strings are null-terminated c) COBOL strings use ASCII; C strings use EBCDIC d) There is no difference on z/OS
4. The CALL-CONVENTION clause appears in which paragraph?
a) FILE-CONTROL b) SPECIAL-NAMES c) REPOSITORY d) INPUT-OUTPUT SECTION
5. The "binary interface pattern" recommends that cross-language parameters use:
a) COMP-3 (packed decimal) exclusively b) DISPLAY numeric exclusively c) COMP (binary) data types exclusively d) A mix of COMP-3 and DISPLAY
6. When a C function needs to modify a COBOL data item, the COBOL program should pass it:
a) BY VALUE b) BY REFERENCE c) BY CONTENT d) It is impossible for C to modify COBOL data
7. In the three-layer Java-COBOL integration architecture, what is the role of the C layer?
a) Business logic processing b) JNI glue code for type conversion between Java and COBOL c) Database access d) User interface rendering
8. The GOBACK statement (rather than STOP RUN) is recommended for COBOL programs called from other languages because:
a) GOBACK is faster b) STOP RUN terminates the entire runtime, including the calling C/Java program c) GOBACK supports return codes d) STOP RUN is deprecated
9. On z/OS, the Language Environment (LE) provides:
a) A web server for COBOL programs b) A common runtime foundation for multiple languages (COBOL, C, Java, PL/I) c) An object-oriented extension to COBOL d) A VSAM file management system
10. When debugging mixed-language programs, the most effective strategy is:
a) Using only the COBOL debugger b) Using only the C debugger c) Adding trace logging at every language boundary d) Rewriting everything in one language
True/False
11. COMP-3 (packed decimal) data can be safely passed directly to a C function without conversion. ___
12. The ALPHABET clause in SPECIAL-NAMES can specify character encoding conversions. ___
13. Assembler routines on z/OS use the same CALL statement as C routines. ___
14. COBOL can natively make HTTP requests without any C or Java assistance. ___
15. When you SET one COBOL POINTER to the address of a data item, it is equivalent to passing BY REFERENCE. ___
Short Answer
16. Explain why passing a PIC 9(8) DISPLAY data item (containing a date like "20250315") directly to a C function that expects an integer is problematic. What conversion is needed?
17. Describe the string null-termination challenge when COBOL calls C. Write pseudocode (or actual COBOL code) for a paragraph that converts a COBOL PIC X(30) string to a C-compatible null-terminated string.
18. In the GlobalBank architecture diagram (Section 26.9), four different languages are used. For each language (Java, C, COBOL, Assembler), explain why that specific language was chosen for its role.
19. What is the difference between CALL-CONVENTION 0 and CALL-CONVENTION 8 in Micro Focus COBOL? When would you use each?
20. James Okafor said the biggest challenge in inter-language programming was "communication between development teams." Why is cross-team communication more difficult with mixed-language systems than with single-language systems?
Answer Key
- b — BY REFERENCE (COBOL passes the address of data items by default)
- b — BY VALUE with PIC S9(9) COMP (matches C int as a 4-byte binary value)
- b — COBOL strings are space-padded and fixed-length; C strings are null-terminated
- b — SPECIAL-NAMES
- c — COMP (binary) data types exclusively
- b — BY REFERENCE (C receives a pointer it can dereference and modify)
- b — JNI glue code for type conversion between Java and COBOL
- b — STOP RUN terminates the entire runtime, including the calling program
- b — A common runtime foundation for multiple languages
- c — Adding trace logging at every language boundary
- False — C has no native packed decimal type; conversion is needed
- True — ALPHABET can specify STANDARD-1 (ASCII), NATIVE (EBCDIC), etc.
- True — COBOL uses the same CALL statement; the compiler generates proper linkage
- False — COBOL needs C libraries (libcurl), CICS web services, or z/OS Connect
- True — Both mechanisms give the called program access to the data at that memory address