Inheritance

Please read

  • 10.1-10.9 of 10. Inheritance of Runestone book Introduction to Programming with Java by Ericson et. al.
  • 8.2.1 and 8.3.1 of Runestone Java, Java, Java: Object-Oriented Problem Solving, 2024E online book by Morelli et. al.
  • subclass, superclass (aka base class)
  • inheritance
  • is-a relationship
  • protected access
  • overriding
  • class hierarchy
  • abstract class
  1. Why do we declare most instance variables as private, except when they are instead declared public static final? Would it be better to declare them all protected, just in case a subclass needs them? Or should we use protected only if absolutely necessary?
  2. What is the purpose of the special function called super? What happens when code containing a super() call runs?
  3. What is the point of abstract classes? Why would you ever want a class that you can’t instantiate?

What was particularly interesting, confusing, or exciting to you in this reading?