English
Summary
Conclusions
A class defines controlled creation and modification of state. Private fields, validated constructors, and domain methods reduce the number of places where an invariant can be violated. Packages organize names, static members express shared properties, and immutability and defensive copies make dependencies between objects easier to reason about.
Self-check questions
- How does a class differ from an instance?
- What values do fields have before explicit initialization?
- Why does copying a reference not copy the object?
- When does the compiler add a default constructor?
- What can be checked before this or super in JDK 27?
- Why should not every field have a setter?
- When should a field be static?
- Why does a final reference not guarantee deep immutability?
- Which root must be passed in the classpath?
- What information should a Javadoc contract contain?