Phase VI
Objects
Define reference types, construct valid objects, and trace identity, calls, and copying.
A class defines a type whose state and behaviour belong together. This phase follows an object from allocation through construction, aliasing, method calls, and measured memory layout. It separates reference values from objects, proves that Java always passes arguments by value, and names the ownership rules behind static and final.
When you finish this phase you can
- Define a class as a reference type with instance state, behaviour, and construction rules
- Trace allocation, default field values, initialization, and the reference produced by new
- Distinguish a compiler-provided default constructor from a declared no-argument constructor
- Chain this and super constructor calls, then predict field, block, and constructor order
- Prove Java passes every argument by value, including copied reference values
- Distinguish aliasing, shallow copying, deep copying, and defensive copying
- Measure one JVM object layout with JOL and state the configuration behind the result
- Explain class initialization, static ownership, final assignment, and compile-time constants
- 6.1Classes, Objects, and `new`Define a class and create objects that each hold their own field values.ClassObjectStateBehaviour
- 6.2Constructors, Chaining, `this`Use constructors to give every new object a valid starting state.Constructor
- 6.3Objects in Memory: Size, Copying, PassingTrace references to explain shared objects, method arguments, copying, and object size.Java is always call by valueShallow vs deep copy
- 6.4`static` and `final`Use static for class-level data and final to prevent specific kinds of change.staticfinal