Recall & Review
beginner
What does it mean to extend an interface in TypeScript?
Extending an interface means creating a new interface that inherits properties and methods from an existing interface, allowing reuse and addition of new members.
Click to reveal answer
intermediate
How do you extend multiple interfaces in TypeScript?
You list multiple interfaces separated by commas after the
extends keyword, like interface NewInterface extends Interface1, Interface2 {}.Click to reveal answer
intermediate
Can an interface extend a class in TypeScript?Yes, an interface can extend a class, inheriting its members but without implementation, allowing the interface to describe the shape of the class.
Click to reveal answer
advanced
What happens if an extending interface redeclares a property from the base interface with a different type?
TypeScript will raise an error if the property types are incompatible, because the extending interface must be compatible with the base interface.
Click to reveal answer
beginner
Show a simple example of extending an interface with one additional property.
Example:<br>
interface Animal {
name: string;
}
interface Dog extends Animal {
breed: string;
}Click to reveal answer
Which keyword is used to extend an interface in TypeScript?
✗ Incorrect
The
extends keyword is used to create a new interface that inherits from another interface.Can an interface extend more than one interface?
✗ Incorrect
An interface can extend multiple interfaces by listing them separated by commas after the
extends keyword.What is the result if an extending interface changes the type of a property from the base interface incompatibly?
✗ Incorrect
TypeScript enforces type compatibility and will throw an error if the property types conflict.
Which of the following is a valid way to extend interfaces?
✗ Incorrect
Interfaces extend other interfaces using the
extends keyword and can list multiple interfaces separated by commas.Can an interface extend a class in TypeScript?
✗ Incorrect
Interfaces can extend classes to inherit their members' types without implementation.
Explain how extending interfaces helps in organizing and reusing code in TypeScript.
Think about how you can build on existing blueprints without rewriting everything.
You got /4 concepts.
Describe the syntax and rules for extending multiple interfaces in TypeScript.
Focus on how to list interfaces and what TypeScript expects.
You got /4 concepts.