1. Polymorphism
    1. basics
      1. Polymorphism
      2. superclass var can refer to an obj in sub
        1. but you cannot call subclass-only methods
        2. you can call if you cast it of a compatible type
      3. System.out.println(e); print obj e, if we have tostring method, it will convert to string
    2. Polymorphism Mechanics
    3. Interpreting inheritance code(in the note folder)
  2. Inheritance and Design
    1. basics
      1. be aware of similarities between classes
      2. think of "if I were to making the change"=>finding the relationship
    2. A Misuse of Inheritance
      1. Substitutability
        1. obj of sub can be successfully used anywhere an obj of superclass is expected
        2. equals in between Point and Point3D does not work is because
        3. equals method needs a symmetrical
    3. Is-a versus Has-a
      1. is a is like is a lawyer
      2. has a is like has a lawyer
    4. backward compatibility
      1. new code work correctly with old code
  3. Interface
    1. basic
      1. do not share code
      2. Interface
        1. consists many methods declarations
        2. treat classes similarly
        3. when a class impl infc, it promises to provide all methods in this interface
        4. like a prof certificate
        5. e.g. Comparable, Cloneable, ActionListener, Serializable, Formattable, Runnable, Iterator
    2. An interface for shapes
      1. public interface Shape {}
      2. header of methods, no body of methods
      3. Abstract Method
        1. method is declared but not implemented
        2. need to implement in the class that implement this interface
      4. cannot instantiated, but declare interface type that can refer to the objects
    3. Implementing an Interface
      1. declare "implements"
      2. implement EACH of methods
      3. public class <name> implements <interface> {}
    4. Benefits of Interfaces
      1. additive not invasive
      2. public class <name> extends <superclass> implements <interface>, <interface>...
  4. Interacting with the Superclass
    1. Calling Overridden Methods
      1. super.<method name>(<expression>, <expression>)
      2. because of overriding, this is the right way to interact with method in super class
    2. Accessing Inherited Fields
      1. when the fields are private
      2. using accessor or mutator to return the value, use that method in sub
    3. Calling a Superclass's Constructor
      1. sub must call super to build a construction
      2. super(<expression>, <expression>)
      3. This action will auto initialize the fields
      4. superclass constructor must be the first statement in the sub constr
    4. DividentStock Behavior
      1. super keywords only for accessing overridden methods or constructors
    5. The object class
      1. no extends: auto extends Object
      2. you can declare a parameter as Object o
    6. the equals method
      1. ==: refer to same obj
      2. the default equals method behaves identically to ==
      3. Object class can refer to any object in Java
      4. when you use the specific type of obj with a method in it, need cast
      5. So that the compiler knows it is processing same type
      6. usually we need to define our own equals method
    7. the instanceof keyword
      1. instanceof
        1. whether a variable refer to a given type
        2. <expression> instanceof <type>
        3. good for avoid compile error in equals method
  5. Inheritance Basics
    1. basics
      1. code reuse
    2. Nonprogramming Hierarchies
      1. Is a Relationship
        1. hierarchical connection, one is the specific version of the other
      2. Inheritance Hierarchy
        1. a set of classes
        2. reuse code between classes
    3. Extending a class
      1. inheritance
      2. superclass
        1. single inheritance
          1. only one superC
      3. subclass
        1. extend superC
        2. public class <name> extends <superC> {}
        3. inherit copies of super
      4. multi-level hierarchy
        1. it is legal to extend a sub when this sub extends super
    4. Overriing methods
      1. Override
        1. new version of method in sub overrides super
        2. name & signiture must match