โ† All CodeSignal Technical Assessment Flashcard Decks

Object-Oriented Programming Flashcards

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

Read the first 7 Object-Oriented Programming flashcards as text
  1. What does the Liskov Substitution Principle (LSP) require?

    Answer: Objects of a superclass should be replaceable with objects of its subclasses without breaking program correctness

    LSP states that if S is a subtype of T, substituting any T object with an S object must not alter the correctness of the program.

  2. What is a design pattern in object-oriented software development?

    Answer: A reusable solution template for commonly recurring problems in software design

    Design patterns are proven, reusable solution templates for common design problems, providing a shared vocabulary and structure without dictating exact code.

  3. Which design pattern ensures that only one instance of a class is ever created and provides a global access point to it?

    Answer: Singleton

    The Singleton pattern restricts instantiation of a class to a single object and provides a class-level method to access that unique instance.

  4. What problem does the Factory design pattern solve?

    Answer: Decoupling object creation from the code that uses the object by delegating instantiation to a factory

    The Factory pattern provides an interface for object creation and lets subclasses or factory methods decide which concrete class to instantiate, promoting loose coupling.

  5. What does the Observer design pattern define?

    Answer: A one-to-many dependency so that when one object changes state all dependents are automatically notified

    Observer sets up a publish-subscribe mechanism where subject objects maintain a list of observers and notify them all whenever their state changes.

  6. What does 'tight coupling' mean in OOP design?

    Answer: Classes are highly dependent on each other's concrete implementations, making change difficult

    Tight coupling means classes directly depend on each other's implementations, so changing one class forces changes in others, reducing maintainability and reusability.

  7. What is the primary purpose of the Decorator design pattern?

    Answer: To add new behaviors to an object dynamically at runtime without altering its class definition

    The Decorator pattern wraps an object with one or more decorator objects that add responsibilities dynamically, offering a flexible alternative to creating many subclasses.