Recall & Review
beginner
What does 'multiple interface extension' mean in TypeScript?
It means one interface can inherit properties and methods from more than one other interface, combining them into a single interface.
Click to reveal answer
beginner
How do you extend multiple interfaces in TypeScript? Show the syntax.
Use the
extends keyword followed by a comma-separated list of interfaces. Example:<br>interface A { a: number; }
interface B { b: string; }
interface C extends A, B { c: boolean; }Click to reveal answer
intermediate
Can a class implement an interface that extends multiple interfaces?Yes. When a class implements such an interface, it must provide all properties and methods from all the extended interfaces.Click to reveal answer
advanced
What happens if two extended interfaces have properties with the same name but different types?
TypeScript will raise an error because the property types conflict. The extending interface must resolve the conflict or avoid incompatible overlaps.
Click to reveal answer
beginner
Example: Write interfaces A and B, then interface C that extends both. Add one property to each. What properties does C have?
interface A { x: number; }
interface B { y: string; }
interface C extends A, B { z: boolean; }<br>Interface C has properties x, y, and z.Click to reveal answer
How do you extend multiple interfaces in TypeScript?
✗ Incorrect
Interfaces extend other interfaces using the 'extends' keyword with a comma-separated list.
If interface C extends interfaces A and B, which properties must a class implementing C have?
✗ Incorrect
The class must implement all properties from A, B, and C.
What error occurs if two extended interfaces have the same property name but different types?
✗ Incorrect
TypeScript reports a type conflict error for incompatible property types.
Which keyword is used by a class to follow an interface?
✗ Incorrect
Classes use 'implements' to follow interfaces.
Can interfaces extend more than two interfaces?
✗ Incorrect
Interfaces can extend any number of interfaces separated by commas.
Explain how multiple interface extension works in TypeScript and why it is useful.
Think about how you can combine different sets of properties into one interface.
You got /4 concepts.
Describe what happens when a class implements an interface that extends multiple interfaces.
Remember the class must fulfill all contracts from all interfaces.
You got /3 concepts.