Polymorphism Flashcards
Phenomenon where a single name may be used to represent multiple types
Polymorphism definition
Additional info:
Polymorphic variable can hold values of different types
Polymorphic function can be applied to arguments of a variety of types
Overriding
Specific type of polymorphism
When there is a method call from an instance of the subtype referenced by the supertype, the method from the subtype is dynamically bound
Objects and behaviors requiring a generic way of handling values in a uniform manner, without worrying about the type
Parametric Polymorphism
Data types that allow for parametric polymorphism, and the functions that allow of it
Generic types; generic functions
In Java, casting up along the type hierarchy is automatic and implicit
Upcasting or broadening conversion
car is-a vehicle
Vehicle c = new Car();
In Java, casing down along the type hierarchy
Down casting or narrowing conversion
Car c = (Car) v;
What is the ‘diamond problem’
Multiple inheritance
Living Thing
/ \
Animal Reptile
\ /
Snake
Completely abstract class that is used to group related methods with empty bodies
Interface