Complete the code to call the parent class constructor using super.
class Animal { name: string; constructor(name: string) { this.name = name; } } class Dog extends Animal { constructor(name: string) { [1](name); } }
In TypeScript, super is used to call the parent class constructor.
Complete the method to call the parent class method using super.
class Animal { speak() { return "Animal sound"; } } class Dog extends Animal { speak() { return [1].speak() + " and Bark"; } }
Use super.methodName() to call a method from the parent class.
Fix the error by completing the constructor to properly call super before using this.
class Person { constructor(public name: string) {} } class Employee extends Person { constructor(name: string, public id: number) { [1](name); this.id = id; } }
In derived classes, you must call super() before accessing this.
Fill both blanks to override a method and call the parent method using super.
class Vehicle { move() { return "Moving"; } } class Car extends Vehicle { move() { return [1].move() [2] " fast"; } }
Use super.move() to call the parent method and + to join strings.
Fill all three blanks to override a method, call the parent method, and add extra text.
class Printer { print() { return "Printing"; } } class ColorPrinter extends Printer { print() { return [1].print() [2] " in color" [3] "!"; } }
Use super.print() to call the parent method and + to join strings.
