Inheritance means importing the characteristics from another object. Or we can say that by this way an object can pass its state and behaviors to its children.
Java allows classes to inherit commonly used state and behavior from other classes. In this example, Bicycle now becomes the superclass of MountainBike.
class MountainBike extends Bicycle {
// new fields and methods defining
// a mountain bike would go here
}
In the above example MountainBike is inhariting the Bicycle which gives MountainBike all fields and methods as Bicycle.