JavaScript | JavaScript OOP | Question 6

Last Updated :
Discuss
Comments

What will the following code log?

JavaScript
class Animal {
    makeSound() {
        console.log("Generic sound");
    }
}
class Dog extends Animal {
    makeSound() {
        console.log("Bark");
    }
}
const pet = new Dog();
pet.makeSound();


Generic sound

Bark

Error

Undefined

Share your thoughts in the comments