What is polymorphism?
Polymorphism lets one operation or abstraction work with values of different concrete types through a common type.
Study 5 Polymorphism with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is polymorphism?
Polymorphism lets one operation or abstraction work with values of different concrete types through a common type.
What do declared and run-time types control?
The declared type determines which operations are available, while the run-time type determines which override executes.
Define dynamic dispatch.
Dynamic dispatch is the run-time selection of an overridden method, using the object's actual run-time type.
How does overriding differ from overloading?
Overloading chooses among different parameter lists mainly from compile-time information; overriding selects an implementation of an existing virtual operation at run time.
What enables a derived member to use dynamic dispatch?
A derived class must override a virtual or abstract member to participate in dynamic dispatch.
What behavior does C# `new` member hiding create?
With `new`, the selected method can depend on the variable's declared type; with `override`, a base-class reference still reaches the derived implementation.
What is interface-based polymorphism?
An interface relationship means a class promises to provide the operations specified by an interface, without requiring shared implementation.
What is duck typing?
Duck typing accepts an object based on the operations it supports rather than requiring explicit inheritance from a named type.
Define substitutability.
Substitutability means a more specific object can replace a more general one without breaking client expectations.
What does the Liskov Substitution Principle require?
The Liskov Substitution Principle requires a subtype to preserve its supertype's behavioral contract, including relevant preconditions, postconditions, and invariants.
What does programming against abstractions mean?
Programming against abstractions makes clients depend on stable capabilities instead of concrete implementations.
Why depend on abstractions?
Depending on abstractions improves changeability, testability, extensibility, and separation of concerns.