Title: Key Concept - Inheritance
Course: CPS 189: Java Certification - Review, Practice & Prepare (Development) > Section: (OLDstyle) Learning Modules

Inheritance

Inheritance is one class, the subclass, inheriting the members (fields and methods) of another class, the superclass.

- The subclass inherits the public and protected members of the superclass.
  - If the subclass and superclass are in the same package, the subclass also inherits the package-private members of the superclass.
- Although a subclass does not inherit the constructor method of the superclass, it may call the method using the super keyword.
- Inheritance is accomplished with the extends keyword in the class declaration.
- Every class has exactly one superclass.
  - Except the Object class
- A superclass may have one or more subclasses.

A subclass may declare a:

- field with the same name as one in the superclass.
  - This hides the field in the superclass.
- method with the same signature as one in the superclass.
  - This overrides the method in the superclass.
- static method with the same signature as one in the superclass.
  - This hides the method in the superclass.

For more information about Inheritance:

- Click this link to view Oracle's documentation: Inheritance