Inheritance Review/Recap
ClassA extends ClassB ClassA now inherits (can access and use) all public and protected elements of ClassB We can expect the behavior from the subclass that the superclass had.
ClassA extends ClassB When the constructor from ClassA is called, it automatically calls the no- argument constructor for ClassB. If ClassB does not have a no-argument constructor, ClassA must explicitly call one of the other constructors from ClassB using the keyword super.
ClassA extends ClassB A subclass is the specialization of the superclass, so we can add instance variables, add methods, change parameters on methods, or change the way methods behave.
ClassA extends ClassB When we have a method that has the same signature in a subclass as one in the superclass, we have method overriding. Method overriding is how we change the behaviors of methods in a subclass.
Inheritance Looking at inheritance in reverse – if we have a lot of commonality amongst some classes, we can create one superclass to generalize amongst the subclasses. Ex) Got a lot of classes that do the same thing? Create a common superclass!
What’s the difference? Method overloading Method inheritance Method overriding