Introduction to Inheritance

Introduction to Inheritance: Introduction to Inheritance: an overview, Generalization vs Specialization, Inheritance in Java, Inheritance and Constructors,…

Updated

  1. Introduction to Inheritance: an overview (Apprentice): Inheritance is an is-a relationship, where a child class such as Archer gets all the variables and methods of its parent class, Character, and adds its own.
  2. Generalization vs Specialization (Apprentice): Generalization moves what classes share into one parent class, and specialization keeps what makes each child class different.
  3. Inheritance in Java (Apprentice): In Java, a child class inherits from a parent class with the extends keyword and then adds its own variables and methods.
  4. Inheritance and Constructors (Journeyman): When a parent class has only constructors with parameters, the child class's constructor must call super(...) with those values as its first line.
  5. Overriding Methods (Journeyman): Override an inherited method with @Override and call super to keep the parent's logic while adding your own.