Fundamentals 4 min read

Understanding Interface Inheritance, Multiple Inheritance, and Abstract Classes in Java

This article explains how Java interfaces can be defined separately from classes, how interfaces can inherit from other interfaces (including multiple inheritance), and how abstract classes are declared and extended, providing clear code examples for each concept.

Java Captain
Java Captain
Java Captain
Understanding Interface Inheritance, Multiple Inheritance, and Abstract Classes in Java

In Java, an interface can be defined independently of a class to provide a contract that specifies method signatures without implementation.

Inheritance was originally class‑based, but interfaces themselves can also inherit from other interfaces to extend their contracts.

Interface inheritance works much like class inheritance; for example, a simple Cup interface can be defined as:

interface Cup {
    void addWater(int w);
    void drinkWater(int w);
}

Building on Cup , a new interface MetricCup adds a method to retrieve the water amount:

interface MetricCup extends Cup {
    int WaterContent();
}

Java classes can inherit only one superclass, but an interface may extend multiple interfaces, enabling multiple inheritance . For instance, a Player interface is defined as:

interface Player {
    void play();
}

A MusicCup interface can extend both Cup and Player and introduce a new display() method:

interface MusicCup extends Cup, Player {
    void display();
}

Java also supports abstract classes , which can declare abstract methods (without bodies) alongside concrete methods. An example abstract class Food is:

abstract class Food {
    public abstract void eat();
    public void happyFood() {
        System.out.println("Good! Eat Me!");
    }
}

When a concrete class extends an abstract class, it must provide implementations for all abstract methods; otherwise, the subclass remains abstract. Abstract classes can also contain data members, which are inherited like normal class fields.

In summary, Java interfaces support single and multiple inheritance, allowing developers to compose behavior contracts, while abstract classes provide a way to define partially implemented types that enforce method implementation in subclasses.

Javaprogramminginterface{}inheritanceMultiple InheritanceAbstract Class
Java Captain
Written by

Java Captain

Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.