Chapter

Composition

From ComputerScienceOne by Dr Chris Bourke

Concepts

  1. What is the relationship between equals() and hashCode()?

    "Objects if two instances are equal (that is, equals() returns true) then they must have the same hashCode() value. This requirement is necessary to ensure that hash table-based data structures operat

  2. How does composition model objects made up of other objects?

    "Another important concept when designing classes is composition. Composition is a mechanism by which an object is made up of other objects. One object is said to “own” an instance of another object.

  3. How should a class manage owned collections and avoid shallow copies?

    "We can take this concept further and design our classes to own collections of other classes. For example, we could define a Course class and then update our Student class to own a collection of Cours

Composition | ComputerScienceOne | Bifalgorithm | Bifalgorithm