Complete the code to declare a class that implements two interfaces.
interface A {
methodA(): void;
}
interface B {
methodB(): void;
}
class MyClass implements [1] {
methodA() {
console.log('A');
}
methodB() {
console.log('B');
}
}In TypeScript, to implement multiple interfaces, list them separated by commas.
Complete the code to correctly declare the class implementing interfaces with methods.
interface Printable {
print(): void;
}
interface Scannable {
scan(): void;
}
class MultiFunctionDevice implements Printable, [1] {
print() {
console.log('Printing');
}
scan() {
console.log('Scanning');
}
}The class implements both Printable and Scannable interfaces, so the second interface is Scannable.
Fix the error in the class declaration to correctly implement two interfaces.
interface X {
doX(): void;
}
interface Y {
doY(): void;
}
class XYDevice implements X [1] Y {
doX() {
console.log('X');
}
doY() {
console.log('Y');
}
}Interfaces are separated by commas in the implements clause, not by & or |.
Fill both blanks to complete the class implementing two interfaces with properties.
interface HasName {
name: string;
}
interface HasAge {
age: number;
}
class Person implements [1], [2] {
constructor(public name: string, public age: number) {}
}The class Person implements HasName and HasAge interfaces as it has name and age properties.
Fill all three blanks to complete the class implementing interfaces with methods and properties.
interface CanRun {
run(): void;
}
interface CanJump {
jump(): void;
}
class Athlete implements [1], [2] {
constructor(public speed: number) {}
[3]() {
console.log('Running fast');
}
jump() {
console.log('Jumping high');
}
}The class implements CanRun and CanJump interfaces. The method run() is defined with the correct name.