Learning objectives
Write a public class with private instance variables, and explain how encapsulation, with private data reached only through public methods, protects the state of every object
Explain that the state of an object is the current values of its instance variables, which gives a has-a relationship, and that each object keeps its own copy of those variables
Write constructors, including overloaded ones, that give every instance variable an initial value, taken from the parameters or from sensible defaults
State the default values Java gives instance variables when a class has no constructor written (0, 0.0, false and null), and explain what becomes of that default constructor once any constructor is written
Write accessor methods that return the value of an instance variable and mutator methods that change it, applying any validation the specification requires
Explain why a constructor that receives a mutable object as a parameter should store a copy of it rather than the reference it was given
Continue with a revision plan
These learning objectives are available to everyone. Sign in with an eligible plan to read the full note and worked examples.
