Recall & Review
beginner
What does the
super keyword do in TypeScript classes?The
super keyword is used to call functions on an object's parent class. It allows access to the parent class's constructor and methods.Click to reveal answer
beginner
When must you call <code>super()</code> in a derived class constructor?You must call <code>super()</code> before using <code>this</code> in a derived class constructor. This ensures the parent class is properly initialized first.Click to reveal answer
intermediate
How do you use <code>super</code> to call a parent class method that is overridden?Inside the child class method, use <code>super.methodName()</code> to call the parent class's version of the method.Click to reveal answer
intermediate
Can <code>super</code> be used outside of class methods or constructors?No, <code>super</code> can only be used inside class constructors or methods to refer to the parent class. Using it outside causes errors.Click to reveal answer
beginner
What happens if you forget to call <code>super()</code> in a derived class constructor?TypeScript will throw an error because the parent class constructor must be called before accessing <code>this</code>. This prevents incomplete initialization.Click to reveal answer
What is the purpose of the
super() call in a derived class constructor?✗ Incorrect
The
super() call initializes the parent class, which must happen before using this in the derived class constructor.How do you call a parent class method named
greet from a child class?✗ Incorrect
Use
super.greet() inside the child class method to call the parent class's greet method.Can you use
super outside of a class method or constructor?✗ Incorrect
super is only valid inside class constructors or methods to access the parent class.What error occurs if you use
this before super() in a derived class constructor?✗ Incorrect
Using
this before calling super() causes a ReferenceError because the parent class is not initialized yet.Which statement about
super is true?✗ Incorrect
super is used to access the parent class's properties and methods from a child class.Explain how and why you use the
super keyword in a TypeScript class constructor.Think about what happens when you create a child class object.
You got /3 concepts.
Describe how to call a parent class method from a child class when the method is overridden.
How do you reach back to the original method?
You got /3 concepts.