Recall & Review
beginner
What is inheritance in JavaScript classes?
Inheritance allows a class (child) to use properties and methods from another class (parent), helping to reuse code and create relationships between classes.
Click to reveal answer
beginner
How do you create a child class that inherits from a parent class in JavaScript?Use the <code>extends</code> keyword in the child class declaration, like <code>class Child extends Parent {}</code>.Click to reveal answer
intermediate
What is the purpose of the <code>super()</code> function in a child class constructor?<code>super()</code> calls the parent class constructor. It must be called before using <code>this</code> in the child constructor to properly initialize the parent part.Click to reveal answer
intermediate
Can a child class override a method from its parent class? How?Yes, by defining a method with the same name in the child class, it replaces the parent's method when called on child instances.
Click to reveal answer
beginner
What happens if you call a method on a child class instance that is not defined in the child but exists in the parent?The method from the parent class is used, showing how inheritance allows child classes to access parent methods if not overridden.Click to reveal answer
Which keyword is used to make a class inherit from another class in JavaScript?
✗ Incorrect
The
extends keyword is used to create a child class that inherits from a parent class.What must you call inside a child class constructor before using
this?✗ Incorrect
super() calls the parent constructor and must be called before accessing this in the child constructor.If a child class has a method with the same name as the parent, which method runs when called on the child?
✗ Incorrect
The child's method overrides the parent's method and runs instead.
What happens if a method is called on a child instance but only exists in the parent?
✗ Incorrect
The method from the parent class runs because the child inherits it.
Which of these is NOT true about inheritance in JavaScript classes?
✗ Incorrect
Child classes do NOT need to redefine all parent methods; they inherit them automatically.
Explain how inheritance works in JavaScript classes and why it is useful.
Think about how a child class can get features from a parent class.
You got /5 concepts.
Describe the role of the super() function in a child class constructor.
Consider what happens when you create a child object that needs parent setup.
You got /3 concepts.