Skip to content

Inheritance: extends, super, and overriding · ⁨继承:extends、super 与重写⁩

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.

中文

继承:在一个类的基础上扩展

  • 继承(inheritance)让一个类复用另一个类的字段和方法。
  • 被扩展的类是父类/超类(superclass);新建的类是子类(subclass)。
  • 子类是一种(is-a)它的父类:Dog(狗)是一种 Animal(动物)。

Animal 超类;Dog 和 Cat 各自 extends 它并重写 speak()

Handout

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩