Object-Oriented Programming, unit: Polymorphism. Core concepts, terminology, and worked-example cues a college student meets for this unit, building on prior units without repeating them. Front: a term, concept, or short problem cue. Back: the definition, explanation, or answer.
38 cards · basic cards · AI-written, checked twice. Edit anything.
- What is polymorphism?
Show answer
The ability of different object types to be treated through a common interface, with type-specific behavior
- What is compile-time (static) polymorphism?
Show answer
Polymorphism resolved during compilation, typically through method overloading
- What is runtime (dynamic) polymorphism?
Show answer
Polymorphism resolved during program execution, typically through method overriding
- What is dynamic dispatch?
Show answer
The runtime process of determining which overridden method implementation to call
- How does polymorphism improve code flexibility?
Show answer
Code can work with objects of different types through a shared interface, without needing to know their specific type
- What is an example of polymorphism using a shared superclass?
Show answer
Calling a 'speak' method on different Animal subclasses, each producing different behavior
- What is parametric polymorphism (generics)?
Show answer
Writing code that works across multiple data types using type parameters
- What is duck typing?
Show answer
A style of polymorphism where an object's suitability is determined by its methods, not its declared type
- What is the benefit of using polymorphism with collections?
Show answer
A single collection can hold different subclass objects and be processed uniformly
- What is an interface's role in enabling polymorphism?
Show answer
Defining a common contract that multiple unrelated classes can implement differently
- What is upcasting, in the context of polymorphism?
Show answer
Treating a subclass object as an instance of its superclass or interface type
- What is downcasting?
Show answer
Converting a superclass or interface reference back into its specific subclass type
- Why can downcasting be risky?
Show answer
It can fail at runtime if the object is not actually an instance of the target subclass
- What is late binding?
Show answer
Deferring the decision of which method implementation to run until runtime
- What is subtype polymorphism?
Show answer
The ability to use a subclass object wherever its superclass or implemented interface type is expected.