Question 0-5

Explain why a subclass's CIR format should begin by matching the CIR format of its superclass.

Solution

The code for an instance method is fixed to match the CIR format of the class. A subclass can inherit the instance method, but the compiler will not generate new code for the subclass. Thus, the code for this inherited method is shared by the superclass and the subclass. Since this generated code will expect instance variables to be located in the CIR as in the superclass's CIR format, the subclass's CIR format should begin by matching this format in order for subclass instances be compatible with this existing code.

Back to Exam Review 0