OOP in JavaScript (original) (raw)

What is a class in JavaScript?

What is the purpose of the constructor method in a JavaScript class?

How do you create an instance of a class in JavaScript?

JavaScript `

class Person { constructor(name) { this.name = name; } }

`

What does the extends keyword do in JavaScript?

What is encapsulation in JavaScript OOP?

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();

`

What is polymorphism in OOP?

What are static methods in JavaScript classes?

What will the following code log?

JavaScript `

class Vehicle { static start() { console.log("Starting vehicle..."); } } Vehicle.start();

`

Which of the following best describes inheritance in JavaScript?

There are 10 questions to complete.

Take a part in the ongoing discussion