Objects

What are they?

  • An object is a specific instance of a class.

Object creation

Dog bubbles = new Dog(2, Sex.FEMALE, "Bubbles", 10.5);
Dog rocky = new Dog(5, Sex.MALE, "Rocky", 5.9);
  • Bubbles and Rocky are objects, they have state as defined in the brackets, which can be used by the methods/behaviour.

  • Now we have instances of the class, we can use their methods.

    • We can ask bubbles and rocky to run, and they will get the message (ie method) and perform that behaviour (run that method)

Pass by reference

Object equality

Last updated

Was this helpful?