Saltar al contenido

Inheritance: extends, super, and overriding

English

Inheritance: building on a class

  • Inheritance lets one class reuse another class's fields and methods.
  • The class you build on is the superclass (parent); the new class is the subclass (child).
  • A subclass is-a kind of its superclass: a Dog is an Animal.

Dog and Cat both extend Animal, inherit speak() and override it with Woof and Meow

Material

Iniciar sesión o crear cuenta

IGCSE, A-Level & AP