Which statement best describes encapsulation in object-oriented design?
9 Designing Object-Oriented Systems Online Quiz Questions
Use this free practice quiz with 20 questions to review 9 Designing Object-Oriented Systems, test your knowledge, and prepare for your next test or exam.
A library system defines a LibraryMember class and then creates a member for ID M-104. Which statement correctly distinguishes the class from the created member?
- A
A class is a blueprint, while an object is a particular runtime instance.
- B
A class is always a runtime instance, while an object is a source-code template.
- C
A class stores only behavior, while an object stores only data.
- D
A class can have no operations, while every object must have public fields.
A checkout component should work with either an email notifier or an SMS notifier without changing its own code. What is the main design benefit of depending on a NotificationService interface?
- A
It stores all notification messages inside the checkout component.
- B
It forces every notification provider to use identical internal data structures.
- C
It lets the checkout component depend on a capability without depending on a concrete provider.
- D
It makes notification failures impossible.
Which two practices support a sound use of inheritance? Select all correct choices.
- A
Use inheritance when the derived type genuinely is a kind of the base type.
- B
Use inheritance whenever it avoids duplicating even a few lines of code.
- C
Check whether every proposed subtype can honor the base type's expectations.
- D
Use inheritance to make replaceable notification services easier to swap at runtime.
Which two benefits are directly associated with using composition and dependency injection in a library system? Select all correct choices.
- A
It guarantees that no interfaces are needed.
- B
It allows components to be replaced independently.
- C
It requires every collaborator to be a subclass of the containing object.
- D
It supports testing with substitutes such as a fake notification service.
True or false: In an encapsulated object-oriented design, every private field should have both a public getter and a public setter.
- A
True
- B
False
True or false: Polymorphism is always preferable to a conditional, even when there are only two stable cases and the behavior is simple.
- A
True
- B
False
What design concept allows code to call feePolicy.calculate(loan, today) through one abstraction while different policy objects provide different implementations?
A member already has the maximum number of active loans allowed by the system. How many additional books should the member's canBorrow() decision permit under that rule? Enter a whole number.
combines state and behavior while controlling access to implementation details, helping an object protect its internal .
A Library contains a catalog and uses checkout and notification services. This is an example of .
A checkout workflow must prevent a member from exceeding the borrowing limit. Explain which object should own that rule, what a checkout coordinator should do, and why this division improves the design.
A library initially sends due-date reminders by email, but configuration may later select SMS and tests need a fake notifier. Which design is most appropriate?
- A
Define a focused notification contract and inject an implementation into the checkout component.
- B
Make
CheckoutServiceinherit from both the email and SMS notification classes. - C
Expose the checkout component's notification fields publicly so callers can replace them.
- D
Put email and SMS conditionals in every class that needs to send a reminder.
A library system needs a checkout workflow involving a member, a book, a loan, and a notification provider. Which design best follows the material's guidance about coordinating use cases and protecting domain rules?
- A
Put every checkout rule in CheckoutService so domain objects remain passive.
- B
Let CheckoutService coordinate the workflow while Member and Loan enforce their own rules.
- C
Put all checkout behavior in Catalog because it knows which books are available.
- D
Let NotificationService create the loan and enforce the member's borrowing limit.
True or false: Composition is often preferable to inheritance when a class needs replaceable policies or services that can be supplied independently.
- A
True
- B
False
Which option best describes the role of an interface in an object-oriented design?
- A
A contract of operations that implementing classes promise to provide
- B
A storage structure that records every concrete class in the system
- C
A superclass that automatically supplies all implementation code
- D
A controller that coordinates every use case in the application
A system has email, SMS, and audit components with overlapping but not identical capabilities. Which interface design best follows the material's guidance?
- A
Create one very broad interface so every service shares the same complete API.
- B
Avoid interfaces because concrete classes are always easier to test.
- C
Use several small interfaces when clients or implementers need different coherent capabilities.
- D
Require every implementing class to provide all operations used anywhere in the system.
A checkout component calls feePolicy.calculate(loan, today) through a common contract, while different policy objects calculate different fees. What design term names this technique?
Which example best demonstrates dependency injection in a checkout service?
- A
CheckoutService always constructs a concrete email provider inside its checkout method.
- B
CheckoutService stores every possible notification implementation and selects one with a large conditional.
- C
CheckoutService inherits from both FeePolicy and NotificationService to reuse their code.
- D
CheckoutService receives a fee policy and notification service as dependencies when it is created.
A library design places overdue-fee calculation, rather than unrelated checkout coordination, in a focused fee-policy component. What design quality describes keeping closely related responsibilities together?
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.