Sobes.tech
Junior — Middle

Do you have experience with object-oriented programming?

sobes.tech AI

Answer from AI

Yes, I have experience working with object-oriented programming (OOP). The main concepts in OOP are classes and objects, encapsulation, inheritance, and polymorphism.

For example, in Node.js, you can create classes and instantiate them:

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

  speak() {
    console.log(`${this.name} makes a sound.`);
  }
}

class Dog extends Animal {
  speak() {
    console.log(`${this.name} barks.`);
  }
}

const dog = new Dog('Sharik');
dog.speak(); // Outputs: Sharik barks.

This approach helps structure the code, making it more readable and maintainable.