Java

Advanced OOP

Dive deeper into OOP with Abstract Classes, Interfaces, and Multiple Inheritance.

By TechCoder TeamLast updated: 2026-06-02
In a Nutshell

Dive deeper into OOP with Abstract Classes, Interfaces, and Multiple Inheritance. This hands-on tutorial focuses on practical implementation of advanced oop concepts.

Advanced OOP

Abstract Classes

An abstract class is a class that cannot be instantiated (you cannot create objects of it).

  • Used to provide a common base for subclasses.
  • Can contain abstract methods (method without body) and regular methods.
abstract class Animal {
  public abstract void animalSound(); // No body
  public void sleep() {
    System.out.println("Zzz");
  }
}

Interfaces

An interface is a completely "abstract class" that is used to group related methods with empty bodies.

  • Keyword: interface.
  • Implementation Keyword: implements.
  • Support Multiple Inheritance: A class can implement multiple interfaces.
interface Animal {
  public void animalSound(); // Interface method (no body)
  public void run();
}

class Pig implements Animal {
  public void animalSound() { System.out.println("Wee wee"); }
  public void run() { System.out.println("Pig running"); }
}

[!NOTE] Java does not support multiple inheritance with classes (extending two classes), but you can implement multiple interfaces!

Abstract Class vs Interface

FeatureAbstract ClassInterface
MethodsAbstract & Non-abstractAll abstract (default methods in Java 8+)
VariablesFinal, non-final, static, etc.Only static final (Constants)
InheritanceCan extend only one classCan implement multiple interfaces
Keywordextendsimplements

Interactive Code

Try implementing an interface!

JAVA PLAYGROUND
⏳ Loading editor…

AI Mentor

Confused about "Java abstract classes and interfaces differences"? Ask our AI mentor for a simplified explanation.

Quiz

Quiz

Question 1 of 3

Can you create an object of an Abstract Class?

Yes
No

Next Steps

We've covered the structure. Now let's handle text and collections of data in Module 6: Strings & Arrays.