Inheritance is what happens when a subclass receives variables or methods from a superclass.

Java does not support multiple inheritance, except in the case of interfaces.

The Cat class in the following example is the subclass and the Animal class is the superclass. Cat recieves eat() method of the Animal class even if we do not write it inside the class.

 public class Animal {

    public void eat() {
        System.out.println("Eat for Animal");
    }
}

public class Cat extends Animal {

    public void eat() {
        System.out.println("Eat for Cat");
    }
}