14 Overriding Methods
After reading lesson 14, you will be able to:
- Write a class that extends from another class
- Write an overridden method in a subclass
- Use the super keyword to reference methods in a parent class
- Use the keyword instanceof on objects
This lesson introduces the topic of overriding methods in Java. In Java, a class can extend another class (referred to as the parent class) if we want the classes to share some or all of the data and methods in the parent class. This is called inheritance. Figure 14.1 is a diagram showing inheritance where class B is the parent class to class A. The extended class is considered a subclass or a child class of the parent class.
Figure 14.1 Inheritance diagram of parent class B and child class A

A method in a child class overrides a similar method in the parent class when it has the exact same method signature. This allows the implementation of the child method to be different than the parent method.
Remember, the method signature includes the return type, the method name, and a parameter list.
Figure 14.2 Diagram of a method signature
