โ† 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 is a constructor in OOP?

    Answer: A special method called automatically when an object is created

    A constructor is a special method invoked automatically upon object creation to initialize its state.

  2. Which design concept is described as 'favoring composition over inheritance'?

    Answer: Building complex behavior by combining simpler objects rather than extending class hierarchies

    Favoring composition means assembling objects with desired behaviors rather than relying on deep inheritance chains, improving flexibility.

  3. What is a 'static' method in OOP?

    Answer: A method belonging to the class rather than any instance

    Static methods belong to the class itself and can be called without creating an instance of the class.

  4. What is the role of the 'this' keyword in OOP languages?

    Answer: Refers to the current object instance

    'this' is a reference to the current object instance, used to differentiate instance variables from local variables.

  5. What is the purpose of a destructor or finalizer in OOP?

    Answer: To perform cleanup operations before an object is garbage collected or destroyed

    Destructors/finalizers release resources like file handles or memory allocations when an object is about to be destroyed.

  6. In OOP, what does 'coupling' refer to?

    Answer: The degree of interdependence between software modules

    Coupling measures how much one class depends on another; low coupling is preferred for maintainability and testability.