OOP – Inheritance (extends), online

Six activities your students do on their own devices. See who's finished, and their scores.

OOP – Inheritance (extends) in one minute

What students need to know

extends is exactly the keyword used to set up inheritance. super() runs the parent's setup logic from within the subclass.

extends creates a subclass that gains the parent's properties and methods. JavaScript is case-sensitive, so it must be lowercase 'extends'.

Mistakes students make

  • 'class' must be lowercase - a capital C causes an error.
  • 'class' is misspelled as 'clas'.
  • 'extends' must be lowercase - a capital E causes an error.
  • 'extends' is misspelled as 'extend'.
PREVIOUS · MODULE 49OOP – Methods
YOU ARE HERE · MODULE 50OOP – Inheritance (extends)
NEXT · MODULE 51Maps – Basics

Discover other journeys with this module

What students will learn in this module

Every question in Module 50

Quick questions

  1. Does extends let a class inherit from another class?AYesBNo
  2. Does super() call the parent class's constructor?AYesBNo
  3. Is 'Extends' with a capital E valid JavaScript syntax?ANoBYes
  4. Must 'super' be written in lowercase?ANoBYes
  5. Is 'extend' (without an s) the correct keyword?AYesBNo

Key terms

Students type the meaning of:

  • extends

Match the pairs

class Dog extends Animal { ... }Match it to what it does
super(name);Match it to what it does
Lets one class inherit properties and methods from anotherMatch it to what it does
Calls the parent class's constructor inside a child classMatch it to what it does
class Dog Extends Animal { ... }Match it to what it does
Super(name);Match it to what it does

Fill in the blanks

  1. class Dog _______ Animal {

    Hint: Type the keyword that lets Dog inherit from Animal.

  2. _____(name);

    Hint: Type the keyword that calls the parent class's constructor.

  3. class Cat _______ Animal {

    Hint: Type the keyword that lets Cat inherit from Animal.

  4. constructor(name) {
    _____(name);
    }

    Hint: Type the keyword that calls the parent class's constructor.

  5. class Puppy _______ Dog {

    Hint: Type the keyword that lets Puppy inherit from Dog.

Spot the error

Question 1

AClass Ant extends Animal {Bconstructor(name) {Csuper(name);D}E}

Question 2

Aclas Bee extends Animal {Bconstructor(name) {Csuper(name);D}E}

Question 3

Alet name = "Rex";Bclass Fox Extends Animal {Cconstructor(name) {Dsuper(name);E}F}

Question 4

Alet name2 = "Tom";Bclass Owl extend Animal {Cconstructor(name) {Dsuper(name);E}F}

Question 5

Aclass Bear extends Animal {Bconstructor(name) {CSuper(name);D}E}