TAW_12 Chapter 3, Inheritance and casting Flashcards
How many super classes can a class have?
A class may only inherit from one super class, but that super class may have inherited from a super class as well
Can signatures be changed when redefining a method?
No
When redefining a method should I specify a signature?
No, because the signature is inherited from the super class
If when redefining a method I just want to add code rather than replace it, how can I call the super class method in my redefinition?
super->method
Can a constructor be redefined?
No, you don’t need to do that because you can create a constructor independent of the super class constructor. It can have it’s own signature. YOU MUST CALL the SUPER->CONSTRUCTOR as part of your new instance constructor. You may need to find the previous super class signature to make sure you supply the parameters
What symbol is used in UML to denote Protected?
#
Protected components are visible…?
In the class and all subclasses
How can a subclass access private attributes of the superclass?
Using public or protected methods of the superclass
Can a subclass have its own class-constructor?
Yes, and it does not need to call the super-class class-constructor as that is called automatically
What is the downcast syntax?
?=