In a subclass subl you want to redefine a component of a superclass superl. How do you achieve this? Note: There are 2 correct answers to this question.
To redefine a component of a superclass in a subclass, you need to do the following12:
You add the clause REDEFINITION to the component declaration in the subclass. This indicates that the component is inherited from the superclass and needs to be reimplemented in the subclass. The redefinition must happen in the same visibility section as the component declaration in the superclass. For example, if the superclass has a public method m1, the subclass must also declare the redefined method m1 as public with the REDEFINITION clause.
You implement the redefined component in the subclass. This means that you provide the new logic or behavior for the component that is specific to the subclass. The redefined component in the subclass will override the original component in the superclass when the subclass object is used. For example, if the superclass has a method m1 that returns 'Hello', the subclass can redefine the method m1 to return 'Hi' instead.
You cannot do any of the following:
You implement the redefined component for a second time in the superclass. This is not possible, because the superclass already has an implementation for the component that is inherited by the subclass. The subclass is responsible for providing the new implementation for the redefined component, not the superclass.
You add the clause REDEFINITION to the component in the superclass. This is not necessary, because the superclass does not need to indicate that the component can be redefined by the subclass. The subclass is the one that needs to indicate that the component is redefined by adding the REDEFINITION clause to the component declaration in the subclass.
Ranee
8 months agoFelix
9 months agoRaina
9 months agoArdella
10 months agoTandra
10 months agoLynelle
10 months agoJoesph
10 months agoJovita
11 months agoBelen
11 months agoPrecious
11 months agoFallon
11 months agoEdelmira
11 months agoMarsha
11 months agoOdelia
12 months agoStaci
12 months agoWai
1 year agoPearlie
8 months agoCatina
9 months agoClaribel
9 months agoGennie
9 months agoLea
1 year agoLouvenia
1 year agoCatherin
1 year agoArlyne
1 year agoMelissia
1 year agoCatherin
1 year agoIraida
1 year agoMakeda
1 year agoFletcher
1 year agoTeddy
1 year agoLakeesha
1 year ago