• ↑↓ pour naviguer
  • pour ouvrir
  • pour sélectionner
  • ⌘ ⌥ ↵ pour ouvrir dans un panneau
  • ←→ pour naviguer
  • esc pour rejeter
⌘ '
raccourcis clavier

The Problem

A class often needs to extend the functionality of another class without modifying the original. The simplest form of reuse is one class inheriting from exactly one parent — a direct “is-a” relationship.

Core Idea

Single Inheritance occurs when one subclass inherits from one superclass. It is the simplest and most common form of inheritance. A single chain Parent → Child exists where the child gains all accessible members of the parent and can add or override behavior.

How It Works

The subclass uses extends ParentClass. All non-private fields and methods are inherited. The subclass can override methods, add new fields, and access parent members via super. Constructor chaining ensures parent construction happens first. The JVM’s method dispatch walks up the single inheritance chain, making method resolution straightforward — at most one parent to check.

Visual Explanation

single_inheritance Parent Parent Class Animal - void eat() - void sleep() Child Child Class Dog extends Animal - void bark() Parent->Child extends

Semantic Network

semantic_single_inheritance THIS Single Inheritance INHER Inheritance THIS--INHER built from MULTI Multilevel Inheritance THIS--MULTI builds into HIER Hierarchical Inheritance THIS--HIER contrasts with

Key Properties

  • One parent, one child: Each subclass has exactly one direct superclass
  • Simplest form: The most basic inheritance relationship in Java
  • extends keyword: Uses the standard Java extends mechanism
  • Constructor chaining: Parent constructor runs before child constructor body
  • Predictable resolution: Method lookup only has one parent to check, no ambiguity
  • implicit Object: If no extends is specified, the class implicitly extends Object

Edge Cases & Gotchas

  • No cyclic inheritance: A class cannot extend itself, directly or indirectly
  • final classes: A final class cannot be subclassed at all
  • Single chain guarantee: You always know where a method comes from — only one parent to check, unlike multiple inheritance

Connections