Free Online Flashcard Deck

3 Encapsulation and Abstraction Free Online FlashCards

Study 3 Encapsulation and Abstraction with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What is encapsulation?

Back

Encapsulation keeps an object’s state and the operations that control that state together, while restricting uncontrolled outside access.

02
Front

What does abstraction present?

Back

Abstraction presents an object’s important capabilities while omitting unnecessary implementation details.

03
Front

What is the purpose of information hiding?

Back

Information hiding prevents clients from depending on implementation details that may change, such as a storage system’s database schema.

04
Front

What does access control define?

Back

Access control defines which code may use a type or member. Common levels include public, private, protected, and internal or package-private.

05
Front

What visibility principle should a class follow?

Back

Use the narrowest visibility that supports the design. This reduces accidental misuse and limits dependencies on implementation details.

06
Front

What is a property?

Back

A property provides field-like syntax while allowing custom behavior when a value is read or changed, such as validation or computation.

07
Front

What is an invariant?

Back

An invariant is a condition that must remain true for every valid object state, such as a date range whose end is not earlier than its start.

08
Front

How does validation differ from normalization?

Back

Validation rejects unacceptable input; normalization transforms acceptable but variable input, such as trimming surrounding whitespace.

09
Front

What does valid-by-construction mean?

Back

A valid-by-construction object is valid immediately after successful construction because its required conditions were checked during creation.

10
Front

Why should a class avoid returning an internal mutable collection?

Back

Returning an internal mutable collection lets callers change private state without following the class’s rules. Use a read-only view, defensive copy, or immutable value instead.

11
Front

Why should a public interface be minimal?

Back

A smaller public interface is easier to understand, test, document, and change because every public member is a potential client dependency.

12
Front

What is the difference between a precondition and a postcondition?

Back

A precondition states what callers must provide before an operation can succeed; a postcondition states what success guarantees afterward.