«^»
7.2. Using inheritance to form a subclass

So far, the classes we have produced have been for objects that are distinct from one another: a date is nothing like a person, and vice-versa. However, there will be occasions when a new class is in fact a more specialized form of another class.

For example, if we now have to produce a program that manipulates data about students, we will need a class to represent a student. Such a class will have a lot in common with the class representing a person which we have already produced. Instead of producing a completely new class for a student, we can derive the Student class from the Person class:

0554: public class Student extends Person {
0555:    ...
0556: }

This is called inheritance: the class Student is said to inherit from the class Person: the class Student is the subclass and the class Person is the superclass.

Note: you cannot derive a subclass from a class that has the modifier final, for example:

0557: public final class String { ... }
Note: unlike C++, in Java, you cannot derive a class from more than one class, i.e., Java does not have multiple inheritance.