Chapter 25 Quiz: Object-Oriented COBOL
Multiple Choice
1. Which COBOL standard first introduced full object-oriented extensions?
a) COBOL 85 b) COBOL 97 c) COBOL 2002 d) COBOL 2014
2. What is the OO COBOL equivalent of Java's this keyword?
a) THIS b) SELF c) ME d) CURRENT
3. The FACTORY section of a class contains:
a) Instance data and instance methods b) Class-level data and class-level methods c) Abstract method declarations only d) Constructor definitions only
4. What keyword is required when a subclass method replaces a parent class method?
a) REPLACE b) REDEFINE c) OVERRIDE d) EXTEND
5. The REPOSITORY paragraph serves what purpose?
a) Stores compiled class objects b) Maps logical class names to physical implementations c) Defines the inheritance hierarchy d) Declares interface contracts
6. Which statement creates a new object in OO COBOL?
a) CREATE BankAccount RETURNING objRef
b) ALLOCATE BankAccount RETURNING objRef
c) INVOKE BankAccount "NEW" RETURNING objRef
d) NEW BankAccount GIVING objRef
7. An untyped object reference (USAGE OBJECT REFERENCE with no class name) can hold:
a) Only references to the base Object class b) A reference to any object c) Only NULL d) Only factory references
8. The INHERITS clause appears in:
a) The ENVIRONMENT DIVISION b) The DATA DIVISION c) The CLASS-ID paragraph d) The REPOSITORY paragraph
9. Which of the following is NOT a valid INVOKE target?
a) An object reference variable b) SELF c) SUPER d) A COBOL paragraph name
10. What does INVOKE SUPER "Withdraw" do in a subclass method?
a) Calls the Withdraw method on the current object b) Calls the parent class's version of Withdraw c) Calls the Withdraw method on all objects in the hierarchy d) Raises a compile error because SUPER cannot specify a method name
True/False
11. OO COBOL supports method overloading (multiple methods with the same name but different parameters). ___
12. A class defined with INTERFACE-ID can contain method implementations. ___
13. The OBJECT section's WORKING-STORAGE is shared across all instances. ___
14. IBM Enterprise COBOL fully supports all OO COBOL features from the 2002 standard. ___
15. Setting one object reference to another copies the underlying object. ___
Short Answer
16. Explain the difference between the FACTORY section and the OBJECT section. Give one example of data that belongs in each.
17. Why does this chapter recommend using COMP (binary) parameters rather than COMP-3 when OO COBOL methods interface with external systems? How does this relate to Chapter 26's binary interface pattern?
18. James Okafor decided against OO COBOL for MedClaim. List three factors that influenced his decision and explain whether you agree.
19. What is the difference between a typed object reference (USAGE OBJECT REFERENCE BankAccount) and an interface reference (USAGE OBJECT REFERENCE Printable)? When would you prefer each?
20. Describe the "OO thinking in procedural code" approach. What specific procedural COBOL techniques can achieve encapsulation and polymorphism without the OO syntax?
Answer Key
- c — COBOL 2002 (ISO/IEC 1989:2002)
- b — SELF
- b — Class-level data and class-level methods (analogous to Java's static members)
- c — OVERRIDE
- b — Maps logical class names to physical implementations (similar to Java's import)
- c —
INVOKE BankAccount "NEW" RETURNING objRef - b — A reference to any object
- c — The CLASS-ID paragraph
- d — A COBOL paragraph name (INVOKE targets objects, SELF, SUPER, or class names)
- b — Calls the parent class's version of Withdraw
- False — OO COBOL does not support method overloading
- False — Interfaces contain only method declarations, not implementations
- False — Each instance gets its own copy of OBJECT WORKING-STORAGE
- False — IBM Enterprise COBOL has partial/limited OO support
- False — It copies the reference, not the object (both point to the same object)