FlashKeepers

Computer Science · College

Object-Oriented Programming, Unit 4: Polymorphism

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.

14 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone
What is polymorphism?
The ability of different object types to be treated through a common interface, with type-specific behavior
What is compile-time (static) polymorphism?
Polymorphism resolved during compilation, typically through method overloading
What is runtime (dynamic) polymorphism?
Polymorphism resolved during program execution, typically through method overriding
What is dynamic dispatch?
The runtime process of determining which overridden method implementation to call
How does polymorphism improve code flexibility?
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?
Calling a 'speak' method on different Animal subclasses, each producing different behavior
What is parametric polymorphism (generics)?
Writing code that works across multiple data types using type parameters
What is duck typing?
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?
A single collection can hold different subclass objects and be processed uniformly
What is an interface's role in enabling polymorphism?
Defining a common contract that multiple unrelated classes can implement differently
What is upcasting, in the context of polymorphism?
Treating a subclass object as an instance of its superclass or interface type
What is downcasting?
Converting a superclass or interface reference back into its specific subclass type
Why can downcasting be risky?
It can fail at runtime if the object is not actually an instance of the target subclass
What is late binding?
Deferring the decision of which method implementation to run until runtime