TypeScript | TypeScript Object Oriented Programming | Question10

Last Updated :
Discuss
Comments

Which of the following is a valid implementation of an interface in a class?

TypeScript
interface Vehicle {
    speed: number;
    move(): void;
}

class Car implements Vehicle {
    speed: number;
    move() {
        console.log(`The car is moving at ${this.speed} km/h`);
    }
}


The class Car correctly implements Vehicle.

The class Car is missing the speed property.

The class Car is missing the move method.

The move method in Car has the wrong return type.

Share your thoughts in the comments