Flashcards · Object-Oriented Programming · Free
Object-Oriented Programming flashcards, generated for you.
Example Object-Oriented Programming study cards to learn from right now — then generate a full set from your own notes (plus a practice quiz) and export to Quizlet or Anki. Free, no account needed.
Example Object-Oriented Programming flashcards
What is the primary goal of Object-Oriented Programming?
To organize code into modular, reusable objects that bundle data (state) and behavior (methods) together, improving maintainability, scalability, and reducing complexity.
Define encapsulation and why it matters in interviews.
Bundling data and methods together while hiding internal details behind a public interface. Trade-off: protects invariants and enables change, but adds indirection and can reduce performance-critical optimizations.
What is the difference between composition and inheritance?
Inheritance: 'is-a' relationship where a subclass reuses parent code. Composition: 'has-a' relationship where objects contain other objects. Trade-off: inheritance enables polymorphism but causes tight coupling; composition is more flexible but requires more delegation.
Explain the Liskov Substitution Principle (LSP) and its practical risk.
A subclass must be usable wherever its parent class is used without breaking behavior. Risk: violating it (e.g., Square overriding Rectangle setWidth) causes silent bugs in polymorphic code and breaks client assumptions.
What is polymorphism and what trade-off does it introduce?
Ability for objects of different types to respond to the same method call. Trade-off: enables flexible, decoupled code but requires indirection (virtual dispatch), is harder to reason about statically, and can hide bugs until runtime.
Define abstraction in OOP and when it can be overused.
Hiding complexity behind simplified interfaces. Risk: premature or excessive abstraction creates unnecessary indirection, makes code harder to follow, and over-engineers for flexibility that never gets used.
Compare tight coupling vs. loose coupling in OOP design.
Tight coupling: classes depend directly on concrete implementations, hard to test/modify. Loose coupling: classes depend on abstractions/interfaces, easier to test and swap. Trade-off: loose coupling adds layers and abstractions that can obscure code flow.
What is the difference between an abstract class and an interface?
Abstract class: can have state, constructors, private/protected members; models 'is-a' relationships. Interface: only defines contracts (historically); models 'capable of' relationships. Trade-off: abstract classes are more powerful but less flexible; interfaces enforce contracts with zero assumptions.
Explain the 'Favor Composition Over Inheritance' principle and why.
Prefer has-a relationships over is-a to avoid brittle hierarchies and deep inheritance chains. Composition is more flexible and testable, but requires writing more delegation code and is less convenient for simple type hierarchies.
What interview trap involves confusing OOP design with actual program behavior?
Assuming a 'clean' object model guarantees good code: perfect encapsulation, deep hierarchies, and heavy abstraction can actually harm readability, performance, and debugging. Interviewers probe whether you optimize for the problem, not for OOP purity.
Make your own Object-Oriented Programming study set
Flashcards for related topics
Studying Object-Oriented Programming to build with AI? MindloomHQ turns it into real skills — structured courses, agent projects, and certificates.
Explore MindloomHQ →