Java Inheritance Keyword: Extends

Benjamin Jul 11, 2026

In the realm of object-oriented programming, particularly in Java, inheritance is a fundamental concept that allows one class to acquire the properties and methods of another. This is achieved through the use of specific keywords. Let's delve into the Java keywords that facilitate class inheritance: 'extends', 'implements', and 'inherit'.

10 Example of this keyword in Java
10 Example of this keyword in Java

Before we dive into these keywords, let's briefly understand what inheritance is. Inheritance is a mechanism in Java where a new class is derived from an existing class. The new class, known as the derived class or subclass, inherits the properties and behaviors of the existing class, known as the base class or superclass.

What is Inheritance in Java with example - Object Oriented Programming Tutorial
What is Inheritance in Java with example - Object Oriented Programming Tutorial

'extends' Keyword

The 'extends' keyword in Java is used to create a subclass that extends the functionality of its superclass. It allows the subclass to inherit the fields and methods of the superclass and also add its own fields and methods.

Keywords in JAVA
Keywords in JAVA

Here's a simple example: Suppose we have a superclass 'Animal' with a method 'makeSound()'. We can create a subclass 'Dog' using the 'extends' keyword, which can inherit this method and add its own method 'bark()'.

Inheriting Methods

The new keyword in Java programming language - Codeforcoding
The new keyword in Java programming language - Codeforcoding

The 'extends' keyword allows the subclass to inherit all the methods of the superclass, except for the methods marked as 'private'.

For instance, if 'Animal' has a method 'eat()', 'Dog' can inherit this method and use it as is, or override it to provide its own implementation.

Inheriting Constructors

Programming Books Archives - Techprofree
Programming Books Archives - Techprofree

Java doesn't support constructor inheritance, but the 'super()' keyword can be used to call the constructor of the superclass from the subclass.

For example, 'Dog' can call the constructor of 'Animal' using 'super()' in its own constructor to initialize the superclass fields.

'implements' Keyword

What is Inheritance in Java – 5 Types, Use and Advantages
What is Inheritance in Java – 5 Types, Use and Advantages

The 'implements' keyword is used to achieve abstraction in Java. It allows a class to achieve multiple inheritance of types, which is not possible with the 'extends' keyword.

Here, a class implements an interface, which is a collection of method signatures without a method body. The class must provide implementations for all the methods declared in the interface.

the key words in this language are used to describe something
the key words in this language are used to describe something
Inheritance in Java Explained | OOP Concepts for Beginners
Inheritance in Java Explained | OOP Concepts for Beginners
10 Examples of Inheritance in Java 🔗
10 Examples of Inheritance in Java 🔗
Super Keyword in Java: Syntax, Uses and Examples - Scientech Easy
Super Keyword in Java: Syntax, Uses and Examples - Scientech Easy
Java List of Keywords (All Reserved Words) | Complete Java Reference Guide
Java List of Keywords (All Reserved Words) | Complete Java Reference Guide
Comprehensive Guide to Java Keywords
Comprehensive Guide to Java Keywords
http://chatgpt.com/g/g-lvtjtj09i-darkhorse-dns
http://chatgpt.com/g/g-lvtjtj09i-darkhorse-dns
Java Exception Handling Made Simple
Java Exception Handling Made Simple
Java Basic Syntax – Identifiers, Modifiers, Variables, Arrays, Enums
Java Basic Syntax – Identifiers, Modifiers, Variables, Arrays, Enums
Keywords in Java - Java Reserved Words - TechVidvan
Keywords in Java - Java Reserved Words - TechVidvan
Top Features of Java Every Beginner Should Know ☕🚀
Top Features of Java Every Beginner Should Know ☕🚀
Sorting ArrayList in Java using Collections.sort() Method
Sorting ArrayList in Java using Collections.sort() Method
Exception Handling in Java | Try Catch Finally Explained with Example
Exception Handling in Java | Try Catch Finally Explained with Example
Java OOP Concepts Every Beginner Must Know 🚀
Java OOP Concepts Every Beginner Must Know 🚀
Static Keyword In Java With Examples And Best Practices - JavaTechOnline
Static Keyword In Java With Examples And Best Practices - JavaTechOnline
Java OOPs Concepts - Object Oriented Programming in Java - TechVidvan
Java OOPs Concepts - Object Oriented Programming in Java - TechVidvan
C# VS JAVA (2026)
C# VS JAVA (2026)
Abstract Class Vs Interface in Java
Abstract Class Vs Interface in Java
a diagram that shows the different types of web pages and what they are used for
a diagram that shows the different types of web pages and what they are used for
Java Keywords
Java Keywords

Implementing Methods

The 'implements' keyword requires the class to provide implementations for all the methods declared in the interface. If the class doesn't provide these implementations, it must be declared as 'abstract'.

For example, if a class implements the 'Runnable' interface, it must provide an implementation for the 'run()' method.

Multiple Inheritance

Java doesn't support multiple inheritance of classes, but it does support multiple inheritance of types through interfaces. A class can implement multiple interfaces using the 'implements' keyword, separated by commas.

For instance, a class can implement both 'Runnable' and 'Comparable' interfaces.

'inherit' Keyword: A Misconception

It's important to note that Java doesn't have an 'inherit' keyword. The terms 'extends' and 'implements' are used instead. The 'inherit' keyword is not recognized by the Java compiler and will result in a syntax error.

However, in other programming languages like C#, 'inherit' is used as a synonym for 'extends'. But in Java, it's crucial to use the correct keywords to avoid confusion and ensure the code compiles correctly.

In conclusion, understanding and correctly using the 'extends' and 'implements' keywords in Java is crucial for writing efficient and maintainable code. It's also important to be aware of the absence of the 'inherit' keyword in Java to avoid potential errors. Happy coding!