Encapsulation, IS-A, HAS-A



  • Encapsulation helps hide implementation behind an interface (or API).
  • Encapsulated code has two features:
  • Instance variables are kept protected (usually with the private modifier).
  • Getter and setter methods provide access to instance variables.
  • IS-A refers to inheritance or implementation.
  • IS-A is expressed with the keyword extends.
  • IS-A, "inherits from," and "is a subtype of " are all equivalent expressions.
  • HAS-A means an instance of one class "has a" reference to an instance of another class or another instance of the same class.