JavaScript OOP Interview Questions from basic to advanced

🟢 Basic Level Questions

1. What is OOP in JavaScript?

👉 A programming paradigm based on objects and classes to structure code.


2. What is a class in JavaScript?

👉 A blueprint to create objects using properties and methods.


3. What is an object?

👉 An instance of a class that contains data (properties) and behavior (methods).


4. What is a constructor?

👉 A special method used to initialize object values when created.


5. What is this keyword?

👉 Refers to the current object.


6. Difference between class and object?

👉 Class = blueprint
👉 Object = real instance


🟡 Intermediate Level Questions

7. What is inheritance?

👉 Mechanism to reuse code from another class using extends.


8. What is encapsulation?

👉 Wrapping data and methods together and restricting direct access.


9. What are private fields in JS?

👉 Variables declared using # and cannot be accessed outside the class.


10. What is polymorphism?

👉 Same method behaves differently in different classes.


11. What is method overriding?

👉 Redefining a parent class method in a child class.

class Animal {
speak() {
console.log("Animal sound");
}
}class Dog extends Animal {
speak() {
console.log("Dog barks");
}
}

12. What is the difference between function constructor and class?

👉 Both create objects, but:

  • Class = modern, cleaner syntax
  • Function constructor = older way

13. What is prototype in JavaScript?

👉 Mechanism by which objects inherit features from another object.


14. What is prototype chain?

👉 Chain of objects used to resolve properties.


15. Difference between __proto__ and prototype?

👉 prototype → property of constructor
👉 __proto__ → reference of object


🔴 Advanced Level Questions

16. What is static method?

👉 Method belongs to class, not object.

class MathUtil {
static add(a, b) {
return a + b;
}
}MathUtil.add(2, 3);

17. What is abstraction?

👉 Hiding implementation details and showing only essential features.


18. Can JavaScript support multiple inheritance?

👉 ❌ No (directly)
👉 ✅ Can be done using mixins


19. What are getters and setters?

👉 Methods to get/set values safely.

class Person {
constructor(name) {
this._name = name;
} get name() {
return this._name;
} set name(value) {
this._name = value;
}
}

20. What is method chaining?

👉 Calling multiple methods in one line.

obj.method1().method2().method3();

21. What is super keyword?

👉 Used to call parent class constructor/method.


22. Difference between shallow copy and deep copy?

👉 Shallow → reference copy
👉 Deep → full independent copy


23. How does JavaScript implement OOP internally?

👉 Using prototype-based inheritance


24. What is mixin?

👉 Technique to add reusable functionality to classes.


25. What are ES6 classes syntactic sugar for?

👉 Prototype-based inheritance


🔥 Bonus Practical Question

26. Create a class with inheritance example

👉 Very common in interviews:

class Vehicle {
constructor(name) {
this.name = name;
} start() {
console.log(this.name + " starting...");
}
}class Car extends Vehicle {
drive() {
console.log(this.name + " driving...");
}
}const c = new Car("BMW");
c.start();
c.drive();

💡 Pro Tip (For Interviews)

Interviewers often check:

  • Clear concept understanding
  • Real-life examples
  • Ability to write small code