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. Achieved via access modifiers (private, protected, public) to control visibility and prevent unauthorized access.
What is the difference between abstraction and encapsulation?
Abstraction hides complexity by exposing only essential features (what an object does). Encapsulation hides implementation details and restricts direct access (how it does it). Abstraction is conceptual; encapsulation is mechanical.
Define inheritance and name one trade-off.
Inheritance allows a class to acquire properties and methods from a parent class, enabling code reuse. Trade-off: creates tight coupling between parent and child; changes to parent can break children. Overuse leads to fragile hierarchies.
What is polymorphism and what are its two main types?
Polymorphism means 'many forms'—same method name behaves differently depending on context. Compile-time (static): method/operator overloading. Runtime (dynamic): method overriding via inheritance or interfaces.
Explain the Liskov Substitution Principle (LSP).
Derived classes must be substitutable for their base classes without breaking functionality. If S is a subtype of T, objects of type S should replace T without altering program correctness. Violation: a Square inheriting from Rectangle breaks LSP.
What is composition and how does it compare to inheritance?
Composition: objects contain instances of other classes ('has-a' relationship) vs. inheritance ('is-a'). Composition is preferred because it avoids rigid hierarchies, reduces coupling, and enables runtime flexibility. Often expressed as 'favor composition over inheritance.'
What is a cohesive class?
A class with high cohesion where methods and attributes are closely related and focused on a single responsibility. High cohesion improves maintainability, reusability, and testability. Low cohesion indicates the class does too much.
Define coupling and explain why low coupling is desirable.
Coupling measures how much one class depends on another. Low coupling means classes are independent; changes in one don't cascade to others. Reduces bugs, simplifies testing, and improves modularity. Achieved via abstractions and dependency injection.
What problem does the Strategy pattern solve?
Strategy encapsulates interchangeable algorithms in separate classes, allowing runtime selection without modifying client code. Solves the problem of needing multiple conditional branches for different behaviors. Adheres to Open/Closed Principle.
When would you choose an interface over an abstract class?
Use interfaces for defining contracts/capabilities across unrelated classes (supports multiple inheritance of interface). Use abstract classes for related classes sharing code/state. In modern languages (Java 8+, C# 8+), interfaces can have default methods, blurring the line; prefer interface for behaviors, abstract class for shared implementation.
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 →