The rules for resolution of names depend on whether the names are specified in a program or in a class definition.
When a program, program B, is directly contained within another program, program A, both programs can define a condition-name, a data-name, a file-name, or a record-name using the same user-defined word. When such a duplicated name is referenced in program B, the following steps determine the referenced resource (these rules also apply to classes and contained methods):
This rule is applied to further containing programs until a valid resource is found.
Within a class definition, resources can be defined within the following units:
If a resource is defined with a given name in the data division of an object definition, and there is no resource defined with the same name in an instance method of that object definition, a reference to that name from an instance method is a reference to the resource in the object data division.
If a resource is defined with a given name in the data division of a factory definition, and there is no resource defined with the same name in a factory method of that factory definition, a reference to that name from a factory method is a reference to the resource in the factory data division.
If a resource is defined within a method, any reference within the method to that resource name is always a reference to the resource in the method.
The normal rules for qualification and uniqueness of reference apply when the same name is associated with more than one resource within a given method data division, object data division, or factory data division.