Impact of Program Design - AP Computer Science A

  1. What is the result of using magic numbers in code?
    Decreases code readability and maintainability. Hard-coded values make code difficult to modify.
  2. Why is refactoring important in program design?
    Improves code structure and readability without changing behavior. Continuous improvement keeps code clean and efficient.
  3. What is the purpose of an interface in Java?
    To define a contract that classes can implement. Ensures consistent behavior across implementing classes.
  4. What does it mean if a system has poor modularity?
    The system is difficult to understand, maintain, and extend. Components are tightly coupled and poorly organized.
  5. Identify the effect of using global variables in a program design.
    Increases the risk of unintended side effects. Shared state creates unpredictable program behavior.
  6. Identify the result of high cohesion within a module.
    Makes the module easier to maintain and understand. Related functionality grouped together improves organization.
  7. Identify the key benefit of using inheritance in program design.
    Promotes code reuse by allowing new classes to inherit properties. Saves development time by building upon existing class functionality.
  8. What is the advantage of using interfaces over abstract classes?
    Allows multiple inheritance of type. Supports multiple inheritance without implementation conflicts.
  9. Define 'abstraction' in object-oriented programming.
    Hiding complex realities while exposing only essential parts. Simplifies interfaces by focusing on what matters to users.
  10. What is the impact of using well-defined interfaces on code flexibility?
    Increases flexibility and reusability of code. Clear contracts enable modular, interchangeable components.
  11. What is the impact of high cohesion in a program module?
    Increases the module's maintainability and understandability. Elements work together toward a single, well-defined purpose.
  12. What is polymorphism in the context of object-oriented programming?
    Ability of different classes to be treated as instances of the same class. Enables method overriding and dynamic method dispatch at runtime.
  13. What is the main advantage of using design patterns?
    Provides proven solutions to common design problems. Reusable templates that reduce development time and errors.
  14. Which principle is violated by exposing internal details of a class?
    Encapsulation. Public access to internals breaks data hiding.
  15. Identify the consequence of low coupling between program modules.
    Reduces dependency and increases module independence. Modules can be modified independently without affecting others.
  16. Which term describes a class's ability to process objects differently based on their data type?
    Polymorphism. Same interface handles different object types appropriately.
  17. Identify the impact of poor design on program scalability.
    Limits the ability to efficiently handle growth and changes. Poor architecture creates bottlenecks and performance issues.
  18. Identify the impact of immutable objects on program design.
    Enhances thread safety and reduces bugs. Unchangeable objects prevent accidental state modification.
  19. What is the main disadvantage of code duplication?
    Increases maintenance effort and error potential. Duplicate code multiplies bugs and maintenance work.
  20. What is the purpose of encapsulation in object-oriented programming?
    To hide the internal state and require all interaction through methods. Data hiding ensures controlled access and maintains object integrity.
  21. What is a potential downside of tight coupling between classes?
    Makes the system harder to change and maintain. High interdependence creates fragile, inflexible systems.
  22. Which principle of design separates the program into distinct sections?
    Modularity. Breaking programs into independent, manageable components.
  23. What is the purpose of a constructor in a class?
    To initialize the object's state when it is created. Sets up initial values and prepares object for use.
  24. Identify the role of comments in program design.
    To enhance code readability and understanding. Documentation helps future developers understand design decisions.

Study these flashcards