โ† All CPP Flashcard Decks

Object-Oriented Programming Concepts Flashcards

6 cards from real CPP practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 6 Object-Oriented Programming Concepts flashcards as text
  1. What does 'cohesion' mean in the context of software design?

    Answer: How well the elements within a module belong together

    High cohesion means the elements of a module are closely related and focused on a single purpose, making code easier to maintain.

  2. Which of the following best describes the 'Open/Closed Principle'?

    Answer: Software entities should be open for extension but closed for modification

    The Open/Closed Principle states that classes should be extensible without requiring changes to existing code, reducing regression risk.

  3. What is the 'Interface Segregation Principle'?

    Answer: Clients should not be forced to depend on interfaces they do not use

    ISP says that large interfaces should be split into smaller, specific ones so implementing classes only depend on methods they actually use.

  4. What is a virtual method in OOP?

    Answer: A method whose behavior can be overridden in a derived class at runtime

    Virtual methods support runtime polymorphism, allowing a derived class to override the base class implementation that gets called through a base reference.

  5. What is the 'Dependency Inversion Principle'?

    Answer: High-level modules should not depend on low-level modules; both should depend on abstractions

    DIP decouples high-level policy from low-level implementation by making both depend on abstractions rather than concrete classes.

  6. What is the difference between an interface and an abstract class?

    Answer: Abstract classes can have state and partial implementation; interfaces define contracts with no (or default) implementation

    Abstract classes can contain fields and method bodies while interfaces define a contract that implementing classes must fulfill.