Free Practice Quiz Question List

8 Object-Oriented Design Principles Online Quiz Questions

Use this free practice quiz with 20 questions to review 8 Object-Oriented Design Principles, test your knowledge, and prepare for your next test or exam.

20 questions
01
True or false
1 point

True or false: In object-oriented design, a class is a blueprint and an object is a particular runtime instance of that class.

  1. A

    True

  2. B

    False

02
Choose one
1 point

Which object-oriented concept combines an object's state and behavior while controlling how other objects access them?

  1. A

    Inheritance

  2. B

    Encapsulation

  3. C

    Polymorphism

  4. D

    Composition

03
Choose one
1 point

An Order object owns its order lines and must calculate a subtotal. According to the Information Expert principle, where should the subtotal calculation usually belong?

  1. A

    Assign subtotal calculation to whichever class has the most methods

  2. B

    Assign subtotal calculation to Order because it owns the order lines

  3. C

    Assign subtotal calculation to the database repository because it stores orders

  4. D

    Assign subtotal calculation to the user interface because it displays the subtotal

04
Choose all
1 point

Which three are benefits of dependency injection as described in the material? Select all correct choices.

  1. A

    Required collaborators are visible at construction time

  2. B

    The class must construct every collaborator internally

  3. C

    Production and test implementations can be substituted

  4. D

    Tests can use stubs, fakes, or other test doubles

05
True or false
1 point

True or false: Inheritance is risky when it is used only to reuse a few methods, because it can create a strong dependency on the parent's implementation.

  1. A

    True

  2. B

    False

06
Written response
1 point

What design approach emphasizes assigning responsibilities to collaborating objects and defining their roles and contractual relationships?

07
Fill in the blank
1 point

Complete the statement: A class whose responsibilities form a focused purpose has , while a design in which classes have few, stable dependencies aims for .

08
Choose one
1 point

A loop stores Circle and Rectangle objects as Shape values and calls shape.area() without checking each concrete class. What design concept explains how the appropriate implementation runs?

  1. A

    The loop must determine each shape's concrete class before calling area

  2. B

    The loop copies the area algorithm into every shape object

  3. C

    Each shape supplies its own implementation of area through a common type

  4. D

    The loop can call area only on Circle objects

09
Choose all
1 point

Which three statements correctly describe why a design might favor composition over inheritance? Select all correct choices.

  1. A

    Different collaborators can provide alternative behavior

  2. B

    Implementation choices can vary without changing the coordinating object

  3. C

    Inheritance is never appropriate in any design

  4. D

    A design can depend on a meaningful contract rather than a concrete implementation

10
Written response
1 point

What design heuristic recommends asking an object to perform an operation instead of extracting its data and performing that operation elsewhere?

11
Fill in the blank
1 point

Complete the statement: The rule helps assign object creation to a closely related class, while the selects concrete implementations and assembles application objects.

12
Open ended
1 point

Design an object-oriented solution for notifying customers about shipped orders. Explain which objects should own shipment eligibility, coordination, message content, delivery, and persistence, and explain why your assignments support changeability and testability.

13
Choose one
1 point

Which design best applies dependency inversion when an ordering policy may use Stripe today and another payment provider later?

  1. A

    CheckoutService constructs StripePaymentProcessor directly so the policy knows its exact provider

  2. B

    PaymentProcessor depends directly on CheckoutService's database schema

  3. C

    CheckoutService depends on PaymentProcessor, while the application boundary supplies StripePaymentProcessor

  4. D

    Each concrete payment provider must expose its internal configuration to the checkout policy

14
Choose one
1 point

Which statement best distinguishes a class from an object?

  1. A

    A class is a runtime instance, while an object is a blueprint.

  2. B

    A class is a blueprint, while an object is a particular runtime instance.

  3. C

    A class stores only behavior, while an object stores only state.

  4. D

    A class and an object are two names for exactly the same concept.

15
Choose one
1 point

Which assessment best applies the principle of cohesion?

  1. A

    A class that contains many methods always has high cohesion.

  2. B

    A class is cohesive when it has no dependencies on other classes.

  3. C

    A class that calculates totals, sends email, writes database records, and formats HTML is likely to have low cohesion.

  4. D

    A class has high cohesion whenever it is divided into many small methods.

16
Choose one
1 point

An Order object owns its order lines, and the system must calculate the order subtotal. Which responsibility assignment best follows the Information Expert principle?

  1. A

    Assign subtotal calculation to Order because it owns the order lines.

  2. B

    Assign subtotal calculation to a user-interface class because users request it.

  3. C

    Assign subtotal calculation to every individual order line and add the results in the controller.

  4. D

    Assign subtotal calculation to the database repository because it persists orders.

17
Choose one
1 point

Given a collection typed as List<Shape>, a loop calls shape.area() without checking whether each element is a circle or rectangle. What design concept explains this behavior?

  1. A

    The loop must create a separate conditional branch for every shape subtype.

  2. B

    The Shape type stores the area of every shape in advance.

  3. C

    Polymorphism requires all shape subtypes to use the same area formula.

  4. D

    Each concrete shape supplies its own area implementation through the common Shape type.

18
True or false
1 point

True or false: Under the Dependency Inversion Principle, an ordering policy should depend directly on StripePaymentProcessor rather than on a stable PaymentProcessor abstraction.

  1. A

    True

  2. B

    False

19
Written response
1 point

What object-oriented concept names the characteristic that distinguishes one object from another even when their initial state is identical?

20
Written response
1 point

What design term names the part of an application responsible for assembling objects and selecting their concrete implementations?