Cards (27)

  • What are the main concepts of object-oriented programming?
    Class, object, instantiation, encapsulation, inheritance
  • Why is the object-oriented paradigm used?
    To organize code around objects and their interactions
  • What are the object-oriented design principles?
    • Encapsulate what varies
    • Favor composition over inheritance
    • Program to interfaces, not implementation
  • What is the focus of object-oriented programming (OOP)?
    Objects and their interactions
  • What is an attribute in the context of an object?
    A data item that describes the object
  • What data types could attributes like suit and rank have?
    String for suit and rank
  • What does a class definition do?
    Defines properties of all objects of the same type
  • What is instantiation in OOP?
    Process of creating an object from a class
  • What is the purpose of a reference variable in OOP?
    Holds the memory address of an object
  • What is the role of methods in OOP?
    Define the behavior of the object
  • How does OOP differ from procedural programming when shuffling cards?
    Deck shuffles itself rather than using a separate subroutine
  • What does the constructor in a class do?
    Sets initial values for attributes
  • What is the name of the constructor method in Python?
    __init__
  • What does encapsulation achieve in OOP?
    Binds attributes and methods to protect data
  • What are getter and setter methods used for?
    Accessing and modifying attribute values
  • What is the significance of access modifiers in encapsulation?
    Specifies which properties can be accessed outside the class
  • How does inheritance benefit code management in OOP?
    Reduces repeated code by inheriting attributes and methods
  • What is polymorphism in OOP?
    Ability of a method to exhibit different behaviors
  • What is aggregation in OOP?
    Defines a one-way "has-a" relationship
  • How does composition differ from aggregation?
    Composition specifies an "is-part-of" relationship
  • What are the advantages and disadvantages of OOP?
    Advantages:
    • Easier to conceptualize real-world objects
    • Prewritten classes support code reuse
    • Easy to maintain due to modularity
    • High level of data protection through encapsulation

    Disadvantages:
    • Can be complex for larger projects
    • Relies on message passing, affecting performance
    • May inherit methods that don't make sense contextually
    • Can consume a lot of memory
  • What does UML stand for?
    Unified Modeling Language
  • What does a class diagram represent in OOP?
    Classes and their relationships in pictorial form
  • What symbols are used in class diagrams for access modifiers?
    +, -, #
  • What is the purpose of inheritance diagrams?
    To show class hierarchies and relationships
  • How does encapsulation contribute to data hiding?
    It restricts direct access to attributes
  • What is the role of message passing in OOP?
    Objects call each other's public methods