You can make a class (called a subclass, derived class, or child class) a specialization of another class (called a superclass, base class, or parent class).
A subclass inherits the methods and instance data of its superclasses, and is related to its superclasses by an is-a relationship. For example, if subclass P inherits from superclass Q, and subclass Q inherits from superclass S, then an instance of P is an instance of Q and also (by transitivity) an instance of S. An instance of P inherits the methods and data of Q and S.
Using subclasses has several advantages:
Restriction: You cannot use multiple inheritance in your COBOL programs. Each COBOL class that you define must have exactly one immediate superclass that is implemented in Java or COBOL, and each class must be derived directly or indirectly from java.lang.Object. The semantics of inheritance are as defined by Java.
The structure and syntax of a subclass definition are identical to those of a class definition: Define instance data and methods in the DATA DIVISION and PROCEDURE DIVISION, respectively, within the OBJECT paragraph of the subclass definition. In subclasses that require data and methods that are to be associated with the subclass itself rather than with individual object instances, define a separate DATA DIVISION and PROCEDURE DIVISION within the FACTORY paragraph of the subclass definition.
COBOL instance data is private. A subclass can access the instance data of a COBOL superclass only if the superclass defines attribute (get or set) instance methods for doing so.
Example: accounts
Example: defining a subclass (with methods)
related tasks
Defining a class
Overriding an instance method
Coding attribute (get and set) methods
Defining a subclass instance method
Defining a factory section
related references
Inheritance, overriding, and hiding (The Java Language Specification)
COBOL class definition structure
(COBOL for Windows Language Reference)