Free Online Flashcard Deck

3 Encapsulation and Information Hiding Free Online FlashCards

Study 3 Encapsulation and Information Hiding 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 groups an object’s state and behavior together while controlling how other code interacts with them.

02
Front

What is information hiding?

Back

Information hiding conceals implementation details that clients do not need to know and exposes a small, meaningful public interface.

03
Front

Why does encapsulation matter?

Back

It protects state from invalid changes, centralizes rules, hides complexity, reduces dependencies, and permits internal representation changes without changing clients.

04
Front

What does access control determine?

Back

Access control determines which code can use a type or one of its members.

05
Front

What is a useful default for access levels?

Back

Choose the most restrictive access level that still supports the required design.

06
Front

What is a property?

Back

A property presents an object characteristic through a field-like interface while allowing code to run when the value is read or written.

07
Front

What does a private property setter provide?

Back

A public getter with a private setter lets clients read the value while preventing arbitrary replacement by client code.

08
Front

What is an object invariant?

Back

An invariant is a condition that remains true for every valid object, such as a nonnegative account balance.

09
Front

Where should object validation occur?

Back

Validate data at the boundary where it enters or changes the object, such as a constructor, setter, factory method, or domain operation.

10
Front

How can a Playlist apply information hiding?

Back

A Playlist can expose addSong, removeSong, and playNext without revealing whether songs use a list, queue, or database.

11
Front

What should a clear public interface express?

Back

A public interface should expose behavior that expresses the object’s responsibility rather than its internal representation.

12
Front

Why avoid returning internal mutable collections?

Back

Returning an internal mutable collection lets callers alter object state without validation; return a read-only view, a copy, or controlled operations instead.