Which statement best distinguishes a class from an object?
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.
An Order object contains a PaymentMethod object and delegates payment work to it. Which OOP relationship does this illustrate?
- A
Composition
- B
Inheritance
- C
Polymorphism
- D
Encapsulation
What is the primary role of an interface in the material's OOP model?
- A
It defines a contract that implementing classes promise to provide.
- B
It stores the complete state of every implementing object.
- C
It forces all implementing classes to inherit from one concrete class.
- D
It automatically prevents all changes to an object's state.
Which two outcomes are supported by effective encapsulation? Select all that apply.
- A
It prevents outside code from arbitrarily corrupting object state.
- B
It guarantees that every class must use inheritance.
- C
It allows internal representation to change without requiring caller changes.
- D
It requires every field to be publicly accessible.
Which two guidelines are consistent with the material's advice about choosing inheritance and composition? Select all that apply.
- A
Use inheritance whenever one class uses another class's methods.
- B
Use inheritance when the subtype genuinely conforms to the base type's promises.
- C
Use composition when a class contains a replaceable component.
- D
Use inheritance whenever it produces the deepest possible hierarchy.
True or false: Inheritance is most appropriate when a subtype conforms to the promises of its base type.
- A
True
- B
False
True or false: Polymorphism requires processing code to contain separate logic for every concrete object type.
- A
True
- B
False
What OOP principle bundles an object's state and behavior while controlling access to its internal details?
What OOP term describes using a common type while allowing an object's actual type to determine the implementation of an operation?
An object's is the information stored in it at a particular time, while its is the work it can perform.
Inheritance represents an relationship, whereas composition represents a relationship.
Explain how the payment example demonstrates polymorphism and why that design allows a new payment type to be added with minimal changes to processPayment.
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?
- A
Inheritance, because every Order is a PaymentMethod.
- B
Inheritance, because PaymentMethod should be the Order's superclass.
- C
Composition, because an Order contains a PaymentMethod as a replaceable part.
- D
Encapsulation, because the Order should expose all payment implementation details.
Which statement best distinguishes a class from an object in object-oriented programming?
- A
A class is a concrete instance, while an object is a blueprint.
- B
A class is a blueprint, while an object is a concrete instance.
- C
A class stores only behavior, while an object stores only state.
- D
A class and an object are two names for exactly the same thing.
True or false: An interface defines operations that an implementing class promises to provide, without necessarily prescribing all of the implementation details.
- A
True
- B
False
A bank account stores a current balance and provides a deposit operation. Which classification is correct?
- A
The account balance is behavior, while depositing money is state.
- B
Both the account balance and depositing money are behavior.
- C
The account balance is state, while depositing money is behavior.
- D
State and behavior are interchangeable terms for methods.
What design term describes the property of a class having a focused purpose instead of combining unrelated responsibilities?
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?
- A
The class protects its internal state and exposes controlled operations.
- B
The class must expose every field publicly so callers can update it.
- C
The class can never change its internal representation.
- D
The class creates a subclass for every invalid input.
Why is inheritance a plausible relationship between SavingsAccount and BankAccount in the material's example?
- A
A SavingsAccount has a BankAccount as a replaceable component.
- B
A SavingsAccount uses a BankAccount only through an unrelated utility.
- C
A SavingsAccount is a kind of BankAccount and can specialize its behavior.
- D
A SavingsAccount and BankAccount must be unrelated because they have different balances.
What design term describes the degree of dependency between classes that object-oriented design aims to minimize?
Related study packs and tools
2 Digital Logic
A 14-question medium-difficulty quiz on Boolean algebra, logic gates, truth tables, and combinational circuits.
03 — Python Programming Fundamentals
A focused set of flashcards covering Python variables, data types, expressions, control flow, functions, input, output, and common programming practices.
04 Conditionals and Boolean Logic
Learn how Boolean expressions, logical operators, and conditional structures let programs make reliable decisions, including how to handle boundaries, branch order, and testing.
6 Computer Memory
Learn how computer memory stores and addresses information, how RAM and ROM differ, and how caches and the memory hierarchy balance speed, capacity, and cost.
07 Trees and Binary Search Trees
A progressive guide to tree structure, binary-tree traversals, binary search tree operations, deletion, balancing, and the way tree height determines time and space costs.
12 — Foundations Capstone: Integrating Computer Science
A practical guide to integrating problem definition, data representation, modular programming, algorithms, complexity analysis, testing, correctness, and ethical evaluation into a responsible computer science capstone.
Interrupts
Reviews how interrupts support event handling and multitasking, and how Linux system calls use the RISC-V `ecall` instruction and register conventions.
OS Processes
This quiz covers process management, context switching and scheduling, multitasking, traps and interrupts, and RISC-V privilege transitions.
Systemcalls
A quiz on operating-system system calls, including privileged-operation requests, process creation and execution with fork, exec, and waitpid, and signal handling.