Inheritance & Abstract Classes in Java

From the Java cheat sheet · Inheritance & Interfaces · verified Jul 2026

Inheritance & Abstract Classes

extends, super, overriding, and abstract base classes.

java
// Quick Reference
class Dog extends Animal {
    @Override
    void speak() { System.out.println("Woof"); }
}
abstract class Animal { abstract void speak(); }
💡 super(...) calls the parent constructor and must be the first statement.
⚡ @Override is optional but lets the compiler catch signature mistakes.
📌 Abstract classes can mix abstract and concrete methods and hold state.
🟢 Polymorphism: a parent-typed reference dispatches to the actual subclass method.
inheritanceabstract

More Java tasks

Back to the full Java cheat sheet