Skip to content · ⁨ข้ามไปยังเนื้อหา⁩

Inheritance: extends, super, and overriding · ⁨การสืบทอด (Inheritance): extends, super และการแทนที่ (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.

ไทย

การสืบทอด: การสร้างบนคลาส

  • การสืบทอด ทำให้คลาสหนึ่งนำฟิลด์และเมทอดของอีกคลาสมาใช้ซ้ำได้
  • คลาสที่เราสร้างบน它就是 superclass (พ่อ); คลาสใหม่คือ subclass (ลูก)
  • subclass เป็น-a ประเภทหนึ่งของ superclass:一个 Dog เป็น-an Animal

An Animal superclass; Dog and Cat each extend it and override speak()

Handout · ⁨เอกสารประกอบการเรียน⁩

Log in or create account · ⁨เข้าสู่ระบบหรือสร้างบัญชี⁩

IGCSE, A-Level & AP