Title: Inheritance Object Class
Course: CPS 161: An Intro to Programming with Java - DL MM MASTER > Section: Learning Units - Bb

Presentations and Videos

- Inheritance Object Class lecture video (Time: 35:00)
- Inheritance Object Class document

- Object class - the mother of all classes
- The Object class contains a number of methods including: equals, toString and getClass.
- The behavior of the default equals and toString methods in the Object class.
- Overriding toString and equals in Person.java to provide useful toString and equals methods.
- Overloading "equals" versus overriding "equals". Note the compiler will pick the version that is the closest fit. However, for the long haul in Java, we want to override the "equals" method.
- Writing a proper "equals" method: boolean equals(Object obj)
  - Check for obj being null
  - Check to make sure that obj is a compatible class that can be appropriately cast
    - Using the getClass approach - recommended by the textbook
    - Using "instanceof"
- Keyword "final"
  - Making a variable constant: final int num_rows =10;
  - Making a class so it can't be extended: final class MyFinalClass
  - Making a method so it can be overriden: final void finalMethod()