Week 2 Flashcards
Name this: “is-a” relationship
Inheritance
Name this: “has-a” relationship
Composition
Inheritance is determined at _______ time, whereas composition is determined at ___ time
compile, run
A subclass if defined in terms of its _________ and can often see the ____________’ internals
superclass. superclass’ internals
In composition a class a_________s with others to gain f____________
associates with others to gain functionality
Name this: Easy to override methods, can’t change at runtime
Inheritnce
Name this: Implementation changes in one level affects its lower level, cascading.
Inheritance
Name this: Respects class interface, interfaces need careful design if they are to be used with many other classes
Composition
Name this: Encapsulation respected, sometimes more classes needed for a solution (more complex)
Composition
For this course: Composition vs Inheritance, which is favoured?
Composition
Object 1 has a reference to object 2 and uses that to access methods in object 2. Object 1 is giving the responsibility of operations to object 2.
Who is the delegator, who is the delegate?
Object 1 is the delegator, Object 2 is the delegate
Is delegation dynamic? What does that mean? Give an example
Yes it is dynamic, which means it can be changed at runtime. Example: Class “Window” can be a shape other than rectangle.
T/F - A delegator may only delegate one delegate object
False. It may delegate multiple delegate objects
T/F - Many delegators may use a single delegate
True
T/F - A delegate may only expose one method for invocvation
False. It may expose multiple methods for invocation.