The class that inherits from another class is called a "subclass" or "derived class". The class that is being inherited from is called a "superclass" or "base class".
When a class inherits from another class, it automatically gets all of the properties and methods of the superclass. The new class can then add its own properties and methods, or it can override the properties and methods of the superclass.
Inheritance is used to create a hierarchy of classes, with each class inheriting from a common ancestor. This makes it possible to reuse code and to create new classes with different functionality.
For example, consider a class called `Animal`. This class might have properties such as `name`, `age`, and `species`. It might also have methods such as `eat()`, `sleep()`, and `move()`.
Now consider a class called `Dog`. The `Dog` class can inherit from the `Animal` class. This means that the `Dog` class will automatically get all of the properties and methods of the `Animal` class. The `Dog` class can then add its own properties and methods, such as a `bark()`, method.
This is a simple example of how inheritance is used to create a new class with different functionality. Inheritance is a powerful tool that can be used to create complex and flexible object-oriented programs.
Here are some additional examples of how inheritance is used in real-world applications:
* The `java.lang.Object` class is the base class for all objects in the Java programming language. Every other class in Java inherits from the `Object` class.
* The `java.util.ArrayList` class is a subclass of the `java.util.AbstractList` class. This means that the `ArrayList` class has all of the properties and methods of the `AbstractList` class, plus it has its own properties and methods.
* The `javax.swing.JButton` class is a subclass of the `javax.swing.JComponent` class. This means that the `JButton` class has all of the properties and methods of the `JComponent` class, plus it has its own properties and methods.