The Two Arrows Beginners Confuse
Every hierarchy diagram has triangle-tipped arrows, and mixing them up changes the meaning entirely: a solid triangle is generalization (extends — is-a, shared identity), a dashed one is realization (implements — acts-as, contract fulfillment). One inherits working machinery and identity; the other promises behavior without receiving anything.
GENERALIZATION (solid) REALIZATION (dashed)
┌───────────┐ ┌──────────────┐
│ Vehicle │ │ Flyable │
│ regNo: Str│ │ + fly(): void│
│ start() │ └──────△───────┘
└─────△─────┘ ┆ implements
│ extends ┆ (promise only)
┌──────┴──────┐ ┌──────┴──────┐
│ Car │ │ Duck │
│ trunkSize │ │ ... │
└─────────────┘ └─────────────┘
Car IS-A Vehicle: gets fields + Duck CAN-DO flying:
inherited behavior; one parent only no state received; many allowed
The inheritance of stuff is the visual difference’s real meaning: generalization transfers fields and method bodies down; realization transfers nothing but an obligation.
Java Mechanics
abstract class Vehicle { // generalized-from side
protected String regNo;
abstract void start();
}
class Car extends Vehicle { // GENERALIZATION
int trunkSize;
@Override void start() { igniteEngine(); }
}
interface Flyable { void fly(); }
class Duck implements Flyable { // REALIZATION
@Override public void fly() { flap(); }
}
// a class realizes MANY interfaces while generalizing ONE class:
class Seaplane extends Vehicle implements Flyable { ... }
Selection Rule
| Question | Yes → |
|---|---|
| Is B genuinely substitutable for A everywhere (LSP)? | Generalize |
| Does B need A’s state/fields? | Generalize (only way to get them) |
| Merely shares a capability across unrelated types? | Realize |
| Capability may be added/removed per instance at runtime? | Realize (+ composition) |
Realization composes better: unlimited count, no slot consumption, swappable. Generalization buys code reuse and identity at the cost of the single-extends budget.
Reading Diagrams Fast
- Triangle always points at the parent/interface.
- Dashed line ⇒ no fields flow; solid line ⇒ expect inherited members.
- Multiple dashed triangles converging on one interface = normal; multiple solid ones from one class = illegal in Java.
Interview Signals
- Correctly labeling both arrow styles on a whiteboard hierarchy is table stakes; interviewers watch for it.
- The experienced framing: “generalization is identity inheritance, realization is capability declaration” — and choosing between them via the LSP substitution test rather than syntax convenience.
Failure Modes
- Using
extendsto grab code without identity (theStack extends Vectormistake pattern). - Fat interfaces realized by classes that stub half the methods — ISP violation wearing realization’s clothing.
Premium Content
Unlock Realization & Generalization and all premium lessons with a subscription.
From ₹199.99/year — See plans