Sitemap
Priyanka

Priyanka

Software developer sharing practical insights on development & modern technology. Writing about concepts, lessons learned & real-world development experiences.

Member-only story

Inheritance in Java

2 min readOct 14, 2026

--

Introduction

Inheritance is one of the most important concepts in Object-Oriented Programming (OOP). In Java, inheritance allows one class to acquire the properties and methods of another class. It promotes code reusability, reduces code duplication, and makes programs easier to maintain.

The class whose properties and methods are inherited is called the parent class (superclass), while the class that inherits them is called the child class (subclass). Java uses the extends keyword to implement inheritance between classes.

Types of Inheritance in Java

Java supports several types of inheritance:

  1. Single Inheritance: One child class inherits from one parent class.
  2. Multilevel Inheritance: A class inherits from a child class, forming a chain of inheritance.
  3. Hierarchical Inheritance: Multiple child classes inherit from the same parent class.
  4. Multiple Inheritance: A class inherits from more than one parent class. Java does not support multiple inheritance through classes, but it supports it through interfaces.

Example of Inheritance in Java

Consider the following example, where a Dog class inherits the properties and methods of an Animal class.

class Animal {
void eat() {
System.out.println("Animal is eating");
}
}
class Dog extends Animal {
void bark() {…

--

--

Priyanka
Priyanka

Written by Priyanka

Software developer sharing practical insights on development & modern technology. Writing about concepts, lessons learned & real-world development experiences.