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 encapsulation in OOP?
Bundling data (attributes) and methods together while hiding internal details behind a public interface. Trade-off: increased complexity vs. reduced coupling and easier maintenance.
Define inheritance and name a key trade-off.
Mechanism where a class (child) derives properties/methods from another class (parent), promoting code reuse. Trade-off: tight coupling between parent and child; breaking parent can break child; can lead to fragile base class problem.
What is polymorphism and its main benefit?
Ability of objects to take multiple forms, allowing the same method call to behave differently based on object type. Benefit: write flexible, extensible code without knowing concrete types at compile time.
Explain composition vs. inheritance. When use each?
Composition: object contains another object as a member (has-a). Inheritance: object extends another class (is-a). Use composition for flexibility and loose coupling; use inheritance only when is-a relationship is clear and stable. Composition favors flexibility; inheritance favors code reuse but creates tight coupling.
What is the Liskov Substitution Principle (LSP)?
Derived classes must be substitutable for base classes without breaking correctness. Trade-off: requires careful design to avoid subclass behavior violating parent contract; violation leads to fragile code relying on type checks.
Define abstraction in OOP. Why is it valuable?
Exposing only essential features while hiding implementation details. Valuable because it reduces cognitive load, allows changing internals without affecting clients, and supports multiple implementations of the same interface.
What problem does the Single Responsibility Principle (SRP) solve?
Classes should have one reason to change (one responsibility). Solves tight coupling, improves testability, and simplifies maintenance. Trade-off: can lead to more small classes, increasing overall complexity if over-applied.
Compare shallow vs. deep object copying. When is deep copy problematic?
Shallow copy duplicates references; deep copy duplicates all nested objects. Deep copy is expensive and risky if objects contain circular references or share state intentionally. Trade-off: deep copy prevents unintended mutations but costs performance and memory.
What is method overriding vs. overloading? Name a trade-off for each.
Overriding: child redefines parent's method (runtime polymorphism). Overloading: same method name with different signatures (compile-time). Override trade-off: risky if subclass breaks contract. Overload trade-off: confusing if too many overloads; harder to find correct version.
Why might deep inheritance hierarchies be problematic in OOP?
Deep hierarchies increase fragility (changes ripple down), reduce readability, make refactoring costly, and encourage tight coupling. Interviewers probe this to see if you understand composition-over-inheritance and can recognize design smell; prefer flat hierarchies or mixins/traits.
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 →