Complete the code to declare a class named Person.
class [1] { name: string; constructor(name: string) { this.name = name; } }
The class is named Person as required.
Complete the code to create an instance of the class Person.
const person = new [1]('Alice');
new keyword.The instance is created from the Person class.
Fix the error in the assignment by choosing the correct class type.
let p: Person; p = new [1]('Bob');
The variable p is of type Person, so the instance must be created from the Person class.
Fill both blanks to create a compatible assignment between classes.
class [1] { name: string; constructor(name: string) { this.name = name; } } let employee: [2]; employee = new Employee('Eve');
The class Employee extends Person compatibility. The variable employee is typed as Person to allow assignment of an Employee instance.
Fill all three blanks to complete the code demonstrating type compatibility with classes.
class [1] { name: string; constructor(name: string) { this.name = name; } } class [2] extends [3] { department: string; constructor(name: string, department: string) { super(name); this.department = department; } }
The base class is Person. The derived class is Employee which extends Person. This shows type compatibility through inheritance.