Free Practice Quiz Question List

1 Object-Oriented Programming Foundations Online Quiz Questions

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

20 questions
01
Choose one
1 point

Which statement best distinguishes a class from an object?

  1. A

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

  2. B

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

  3. C

    A class is a method, while an object is an access modifier.

  4. D

    A class is an interface, while an object is a constructor.

02
Choose one
1 point

An Order object contains a PaymentMethod object and delegates payment work to it. Which OOP relationship does this illustrate?

  1. A

    Composition

  2. B

    Inheritance

  3. C

    Polymorphism

  4. D

    Encapsulation

03
Choose one
1 point

What is the primary role of an interface in the material's OOP model?

  1. A

    It defines a contract that implementing classes promise to provide.

  2. B

    It stores the complete state of every implementing object.

  3. C

    It forces all implementing classes to inherit from one concrete class.

  4. D

    It automatically prevents all changes to an object's state.

04
Choose all
1 point

Which two outcomes are supported by effective encapsulation? Select all that apply.

  1. A

    It prevents outside code from arbitrarily corrupting object state.

  2. B

    It guarantees that every class must use inheritance.

  3. C

    It allows internal representation to change without requiring caller changes.

  4. D

    It requires every field to be publicly accessible.

05
Choose all
1 point

Which two guidelines are consistent with the material's advice about choosing inheritance and composition? Select all that apply.

  1. A

    Use inheritance whenever one class uses another class's methods.

  2. B

    Use inheritance when the subtype genuinely conforms to the base type's promises.

  3. C

    Use composition when a class contains a replaceable component.

  4. D

    Use inheritance whenever it produces the deepest possible hierarchy.

06
True or false
1 point

True or false: Inheritance is most appropriate when a subtype conforms to the promises of its base type.

  1. A

    True

  2. B

    False

07
True or false
1 point

True or false: Polymorphism requires processing code to contain separate logic for every concrete object type.

  1. A

    True

  2. B

    False

08
Written response
1 point

What OOP principle bundles an object's state and behavior while controlling access to its internal details?

09
Written response
1 point

What OOP term describes using a common type while allowing an object's actual type to determine the implementation of an operation?

10
Fill in the blank
1 point

An object's is the information stored in it at a particular time, while its is the work it can perform.

11
Fill in the blank
1 point

Inheritance represents an relationship, whereas composition represents a relationship.

12
Open ended
1 point

Explain how the payment example demonstrates polymorphism and why that design allows a new payment type to be added with minimal changes to processPayment.

13
Choose one
1 point

A design team wants an Order to support credit-card and gift-card payment objects interchangeably and to replace the payment object without rewriting Order's core logic. Which design choice best fits the material?

  1. A

    Inheritance, because every Order is a PaymentMethod.

  2. B

    Inheritance, because PaymentMethod should be the Order's superclass.

  3. C

    Composition, because an Order contains a PaymentMethod as a replaceable part.

  4. D

    Encapsulation, because the Order should expose all payment implementation details.

14
Choose one
1 point

Which statement best distinguishes a class from an object in object-oriented programming?

  1. A

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

  2. B

    A class is a blueprint, while an object is a concrete 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 thing.

15
True or false
1 point

True or false: An interface defines operations that an implementing class promises to provide, without necessarily prescribing all of the implementation details.

  1. A

    True

  2. B

    False

16
Choose one
1 point

A bank account stores a current balance and provides a deposit operation. Which classification is correct?

  1. A

    The account balance is behavior, while depositing money is state.

  2. B

    Both the account balance and depositing money are behavior.

  3. C

    The account balance is state, while depositing money is behavior.

  4. D

    State and behavior are interchangeable terms for methods.

17
Written response
1 point

What design term describes the property of a class having a focused purpose instead of combining unrelated responsibilities?

18
Choose one
1 point

A bank-account class keeps its balance private and requires callers to use validated methods for updates. What object-oriented principle is most directly illustrated?

  1. A

    The class protects its internal state and exposes controlled operations.

  2. B

    The class must expose every field publicly so callers can update it.

  3. C

    The class can never change its internal representation.

  4. D

    The class creates a subclass for every invalid input.

19
Choose one
1 point

Why is inheritance a plausible relationship between SavingsAccount and BankAccount in the material's example?

  1. A

    A SavingsAccount has a BankAccount as a replaceable component.

  2. B

    A SavingsAccount uses a BankAccount only through an unrelated utility.

  3. C

    A SavingsAccount is a kind of BankAccount and can specialize its behavior.

  4. D

    A SavingsAccount and BankAccount must be unrelated because they have different balances.

20
Written response
1 point

What design term describes the degree of dependency between classes that object-oriented design aims to minimize?