Polymorphism
Polymorphism is an object-oriented programming principle that allows objects of different classes to be treated through a common interface, with each object responding to the same method call according to its own specific implementation.
41 resources across 4 libraries
Glossary Terms(6)
Interfaces
An interface defines a contract of methods and properties that a class or object must implement, specifying what operations are available without dictating how…
Abstract Class
An abstract class is a class that cannot be instantiated directly and is designed to be subclassed, often providing shared implementation alongside one or more…
Polymorphism
Polymorphism is an object-oriented programming principle that allows objects of different classes to be treated through a common interface, with each object re…
Inheritance
Inheritance is an object-oriented programming mechanism that allows a class to acquire the properties and methods of another class, letting a subclass reuse an…
Encapsulation
Encapsulation is an object-oriented programming principle that bundles data and the methods that operate on it within a single unit (a class), while restrictin…
Duck Typing
Duck typing is a style of dynamic typing in which an object's suitability for use is determined by the presence of the methods and properties it supports, rath…
Study Notes(7)
Classes in D
How D's reference-type classes work: single inheritance, polymorphism, the Object root, and construction/destruction lifecycle.
Multimethods and Protocols
Explore Clojure's two mechanisms for open, extensible polymorphism — arbitrary-dispatch multimethods and fast, type-based protocols — and learn when to use eac…
Polymorphism in Java
Explore compile-time and runtime polymorphism in Java, including method overloading, overriding, and dynamic dispatch.
Polymorphism in Python
How different objects can respond to the same method call or operator in their own way, enabled by duck typing.
Polymorphism and Abstraction
Distinguishing polymorphism (same interface, different implementations) from abstraction (hiding implementation details) using Python's abc module.
Abstract Classes and Polymorphism
Abstract classes define a partial implementation and a contract that subclasses must complete, enabling polymorphic code that treats different concrete types u…
Polymorphism Explained
See how C# achieves polymorphism through virtual method dispatch, interface implementations, and method/operator overloading, letting one code path handle many…
Cheat Sheets(1)
Interview Questions(27)
What is Polymorphism in OOP?
Polymorphism is the object-oriented principle that lets objects of different classes respond to the same method call in their own class-specific way.
What are the Four Pillars of OOP?
The four pillars of object-oriented programming are Encapsulation, Abstraction, Inheritance, and Polymorphism — the principles that structure code around objec…
Method Overloading vs Overriding
Method overloading is defining multiple methods with the same name but different parameter lists within a class, resolved at compile time, while method overrid…
Static vs Instance Methods: What is the Difference?
A static method belongs to the class itself and is called without any object instance, while an instance method belongs to a specific object and operates on th…
What is Method Overriding in OOP?
Method overriding is when a subclass provides its own implementation of a method already defined in its superclass, using the same name and signature.
What is a Virtual Function?
A virtual function is a member function declared in a base class that a derived class can override, with the actual implementation resolved at runtime based on…
What is the Liskov Substitution Principle?
The Liskov Substitution Principle (LSP) states that objects of a subclass must be substitutable for objects of the base class without altering the correctness…
What is the Strategy Pattern?
The Strategy pattern defines a family of interchangeable algorithms, encapsulates each one behind a common interface, and lets the client swap the algorithm at…
What is the State Pattern?
The State pattern is a behavioral design pattern that lets an object change its behavior when its internal state changes, by delegating state-specific logic to…
What is the Visitor Pattern?
The Visitor pattern is a behavioral design pattern that lets you add new operations over a fixed set of related classes without modifying those classes, by mov…
What is Method Hiding in OOP?
Method hiding occurs when a subclass defines a static method with the same signature as a static method in its superclass, so the method that runs is chosen at…
Covariance and Contravariance Explained
Covariance and contravariance describe how subtyping relationships between types carry over to derived types like arrays, generics, and function signatures — c…
What is Operator Overloading in OOP?
Operator overloading is the object-oriented feature that lets a class redefine what a built-in operator, such as +, ==, or [], means when applied to its own ob…
What is Polymorphic Dispatch?
Polymorphic dispatch is the runtime mechanism by which a call to a method through a base-type reference or interface is routed to the specific implementation d…
What is an Abstract Method?
An abstract method is a method declared with a signature but no body, defined only inside an abstract class or interface, which every concrete subclass or impl…
Concrete Class vs Abstract Class
A concrete class is a fully implemented class that can be instantiated directly with `new`, while an abstract class may leave one or more methods unimplemented…
Liskov Substitution Violation: A Concrete Example
A classic Liskov Substitution Principle violation is a Square class extending a Rectangle class: because setting a Square’s width must also change its height (…
What is Replace Conditional with Polymorphism?
Replace Conditional with Polymorphism is the refactoring that removes a branching statement — usually a switch or if/else chain keyed on an object’s type — by…
Singleton vs Static Class
A Singleton is a regular class restricted to exactly one instance that is still a real object — it can implement interfaces, be passed around, be subclassed, a…
What is the Null Object Pattern?
The Null Object pattern replaces the use of a null reference with a real object that implements the same interface but provides neutral, do-nothing behavior, s…
What is Multiple Dispatch?
Multiple dispatch is a form of polymorphism in which the specific method implementation invoked is chosen at runtime based on the runtime types of more than on…
Single Dispatch vs Multiple Dispatch
Single dispatch selects which method implementation to run based on the runtime type of only the receiver object the method is called on, while multiple dispat…
What is Double Dispatch in OOP?
Double dispatch is a technique where the method that executes is selected based on the runtime types of TWO objects involved in a call, not just one, achieved…
How Does the Visitor Pattern Use Double Dispatch?
The Visitor pattern lets you add new operations over a fixed class hierarchy without modifying the hierarchy itself, by defining an accept(Visitor) method on e…
Showing 24 of 27.