In Java, inheritance is attained by using two keywords “extends” and “implements”. It contains two classes, such as the “base” class which is known as the parent class and the “drive” class is known as the child class. It is the procedure by which one class is permitted to inherit the functionality of another specified class.
In this discussion, we will discuss the “implements” and “extends” keywords in Java with the aid of examples.
Explain the “implements” and “extends” Keywords in Java
The “extends” keyword enhances the functionalities of the child class by inheriting all the methods and functionalities of the parent classes. However, the “implements” does not inherit the functionalities of the parent class instead when implementing an interface in the class from the same or an external file. Only abstract methods are present in an interface that is defined in a class according to the required functionality.
Example 1: “extends” Keyword Working in Java
Now, check out the following block of code for a better understanding of the usage of the “extends” keyword in Java:
class Shape {
void shape_type() {
}
}
class Circle extends Shape {
void shape_type() {
System.out.println("This is a circle.");
}
}
class Square extends Shape {
void shape_type() {
System.out.println("This is a square.");
}
}
class Main {
public static void main(String[] args) {
Circle c = new Circle();
Square s=new Square();
c.shape_type();
s.shape_type();
}
}
In the above-given code example:
- Initially, declare “Shape” as a parent class that contains the “shape_type()” method for storing the shapes.
- Then, declare two child classes “Circle” and “Square” that extends the parent class “Shape”.
- Inside the “main()” method, create the objects of the child classes “c” for Circle and “s” for Square respectively by utilizing the “new” keyword along with the constructors, such as “Circle()” and “Square()”.
- To get the result, call the “shape_type()” method via created child objects.
Here is the output of the above-discussed code:

Example 2: “implements” Keyword Working in Java
To check the working of the “implements” keyword in Java, try out the following example:
interface Animal {
void animal_type();
}
class Tiger implements Animal {
public void animal_type() {
System.out.println("Tiger is mammal.");
}
}
class Turtle implements Animal {
public void animal_type() {
System.out.println("Turtle is reptile.");
}
}class Result {
public static void main(String[] args) {
Animal Tiger = new Tiger();
Tiger.animal_type();
Animal Turtle = new Turtle();
Turtle.animal_type();
}
}
According to the above-stated code block:
- First, define the interface “Animal” that contains the “animal_type()” method to show the type of animal.
- After that, declare two child classes named “Tiger” and “Turtle” that implement the interface “Animal” by utilizing the “implements” keyword.
- and use the “animal_type” method to store the type of animal.
- Lastly, declare the “main()” class named “Result” which contains the objects of the above-discussed child classes.
- To view the results, invoke the “animal_type()” method with created objects.
Output

Conclusion
The “extends” and “implements” are reserved keywords that are used for inheritance in Java. The “extends” keyword inherits the properties of its parent class and creates an “is-a” connection. Whereas “implements” does not inherit the properties instead it creates interfaces. In this guide, we have briefly explained the working of the “extends” and “implements” keywords in Java.