The class that is doing the inheriting is called the child class. It inherits access to the object instance variables and methods in the parent class.
Class
defines a type and is used to define what all objects of that class know and can do.
Declared type
The type that was used in the declaration. List aList = new ArrayList() has a declared type of List. This is used at compile time to check that the object has the methods that are being used in the code.
Descendant class
extends keyword
Used to specify the parent class to inherit from. It is followed by the name of the parent class, like this: public class ChildName extends ParentName. If no extends keyword is used in the class declaration, then the class will automatically inherit from the Object class.
Inheritance
One class can inherit object instance variables and methods from another. This makes it easy to reuse another class by extending it (inheriting from it). This is called specialization. You can also pull out common instance variables and/or methods from several related classes and put those in a common parent class. This is called generalization.
Instantiated type
See run-time type
Method overloading
Method overriding
A child class can have the same method signature (method name and parameter list) as a parent class. Since methods are resolved starting with the class that created the object, that method will be called instead of the inherited parent method, so the child method overrides the parent method.
Object
Objects do the action in an object-oriented program. An object can have things it knows (attributes) and things it can do (methods). An object is created by a class and keeps a reference to the class that created it.
Parent class
One class can inherit from another and the class that it is inheriting from is called the parent class. The parent class is specified in the class declaration using the extends keyword followed by the parent class name.
Polymorphism
The runtime type of an object can be that type or any subclass of the declared type. All method calls are resolved starting with the class that created the object. If the method isn’t found in the class that created the object, then it will look in the parent class and keep looking up the inheritance tree until it finds the method. The method must exist, or the code would not have complied.
Run-time type
The type of the class that created the object. List aList = new ArrayList() has a run-time type of ArrayList. This is used at run-time to find the method to execute.
static keyword
means that the field or method exists in the object that defines the class.
Subclass
See child class
super keyword
Keyword used to call a method in a parent class. This is useful if a child class overrides an inherited method, but still wants to call it.