For example, we might have a general DrawableObject class and refine that to particular drawable objects, such as Circle or Square . With the extends keyword. That is, it can use those methods and fields without explicitly defining or declaring them. A subclass may also override any of these methods by including its own definition. That is, if a class defines any methods with the same name and argument types as the superclass, then that method is used instead.
Inheritance is used in two ways.
First, it's used to automatically provide some core functionality. In addition, it's used guarantee the functions an object will provide. Since an object inherits all of the ancestors methods, someone using the object knows that they will all be available. Java allows you to use a member of a subclass anywhere a member of a superclass is permitted. Note that if you do not provide an extends clause, Java assumes that your object extends java.lang.Object .