Object-Oriented Programming (OOP) in JavaScript allows developers to structure applications into modular, reusable objects that pair state (properties) with behavior (methods). Unlike class-based OOP languages like Java or C++, JavaScript natively uses prototypal inheritance, where objects inherit properties and methods directly from other objects via prototype chains (__proto__ and prototype). ES6 introduced class syntax (class, constructor, extends, super) as syntactical sugar over this underlying prototype model, alongside modern enhancements like private class fields (#field), static methods, and accessor properties (get/set). Understanding object instantiation, prototypal delegation, method overriding, and dynamic this resolution is essential for building scalable web architectures and excelling in technical software engineering assessments.
JavaScript OOP MCQs for Developer Interviews & Certification
1 min read
Correct Answer: a) `__proto__` is an internal property on all objects pointing to their prototype, while `prototype` is a property on constructor functions used to build instances.
Explanation:
`__proto__` exists on every object to link to its prototype for delegation, whereas `prototype` is a property found on constructor functions and classes used to establish the prototype chain for created instances.
Correct Answer: a) A new empty object is created, its prototype is linked to the constructor's prototype, 'this' is bound to the new object, and the object is returned implicitly.
Explanation:
The `new` operator automates four key steps: object creation, prototype linking, `this` binding, and implicit return (unless an explicit object is returned).
Correct Answer: a) "function"
Explanation:
In JavaScript, ES6 classes are syntactical sugar over prototype-based constructor functions, so typeof a class returns "function".
Correct Answer: b) No, they are hoisted like let/const into the Temporal Dead Zone and cannot be accessed before declaration.
Explanation:
Class declarations are hoisted to their scope block, but they remain uninitialized in the Temporal Dead Zone until execution reaches the declaration line.
Correct Answer: a) "Bark"
Explanation:
Method overriding allows the child class `Dog` to provide a specialized implementation of `speak()`, shadowing the parent `Animal` method.
Correct Answer: b) super
Explanation:
The `super` keyword is used in derived classes to call parent constructors (`super()`) or reference parent prototype methods (`super.method()`).
Correct Answer: a) 1
Explanation:
Private fields prefixed with `#` can be accessed and modified within class body methods. Incrementing `#count` from 0 yields 1.
Correct Answer: b) It throws a SyntaxError during parsing.
Explanation:
Attempting to access private fields from outside their defining class declaration raises an immediate SyntaxError.
Correct Answer: a) static myMethod() {}
Explanation:
The `static` keyword defines static methods or fields that belong to the class constructor itself rather than instances.
Correct Answer: b) No, 'this' inside a static method refers to the class constructor function itself, not any instance.
Explanation:
Inside static methods, `this` points to the class constructor, so instance-specific properties cannot be accessed directly.
Correct Answer: a) true
Explanation:
The `instanceof` operator checks if `Animal.prototype` appears anywhere along the prototype chain of instance `d`.
Correct Answer: a) By overriding `Symbol.hasInstance` static method
Explanation:
Classes can define a static `[Symbol.hasInstance](instance)` method to customize custom `instanceof` evaluation logic.
Correct Answer: a) It points back to the constructor function that created the instance.
Explanation:
Every prototype object has a `constructor` property pointing by default to the constructor function that owns the prototype.
Correct Answer: b) It is lost (or points to Object), so it must be manually re-assigned if needed.
Explanation:
Replacing `prototype` with a new object literal wipes out the default `constructor` link, requiring explicit `constructor: Dog` re-assignment.
Correct Answer: a) They naturally encapsulate private state without requiring special syntax like `#` fields.
Explanation:
Factory functions leverage closures to maintain completely private variables and methods without syntax tokens like `#`.
Correct Answer: a) When an object delegates property lookups up its prototype chain if a property is not found locally.
Explanation:
JavaScript uses delegation: if an object lacks a property, the engine looks up the chain to its prototype (`__proto__`).
Correct Answer: a) Dog.prototype
Explanation:
`Object.getPrototypeOf(d)` returns the immediate prototype of instance `d`, which is `Dog.prototype`.
Correct Answer: a) Animal.prototype
Explanation:
In an ES6 class inheritance hierarchy, child prototype delegates to parent prototype (`Dog.prototype.__proto__ === Animal.prototype`).
Correct Answer: a) "Alice"
Explanation:
A getter method prefixed with `get` is accessed like a property (without parentheses), returning "Alice".
Correct Answer: b) A TypeError is thrown.
Explanation:
In strict mode, attempting to assign to a getter-only property throws a TypeError.
Correct Answer: a) Mixins
Explanation:
Mixins provide behavior sharing by copying or delegating methods across independent objects since JavaScript lacks multiple class inheritance.
Correct Answer: a) A design pattern that restricts class instantiation to a single object instance.
Explanation:
The Singleton pattern ensures a class has only one instance and provides a global access point to it.
Correct Answer: a) By storing an instance check inside a static property or constructor return override.
Explanation:
A constructor can check if an instance already exists in a static field; if so, it returns that existing instance.
Correct Answer: a) It creates an object with no prototype, meaning it lacks methods like `toString` or `hasOwnProperty`.
Explanation:
Passing `null` to `Object.create` produces a dictionary object completely detached from `Object.prototype`.
Correct Answer: a) Returning `this` from instance methods so multiple method calls can be chained together in a single statement.
Explanation:
Method chaining relies on methods returning the current instance (`return this`), allowing syntax like `obj.setName('A').setAge(10).save()`.
Correct Answer: a) Defining custom behavior for fundamental object operations like property lookup, assignment, and function invocation.
Explanation:
A `Proxy` wraps an object and intercepts operations using traps (like `get`, `set`, `has`), enabling powerful metaprogramming.
Correct Answer: a) A built-in object providing methods for interceptable JavaScript operations corresponding to Proxy traps.
Explanation:
`Reflect` provides static methods that mirror runtime operations, often used inside Proxy traps to forward operations to the target object.
Correct Answer: a) A ReferenceError is thrown.
Explanation:
In ES6 classes, `this` is uninitialized in a derived constructor until `super()` establishes the parent instance context.
Correct Answer: a) Yes, built-in constructors can be subclassed seamlessly.
Explanation:
ES6 classes allow subclassing native built-ins like `Array`, `Error`, `Map`, and `Date` directly.
Correct Answer: a) The ability of different classes to respond to the same method call with specialized behaviors.
Explanation:
Polymorphism allows objects of different types to share a common interface while implementing distinct internal logic (e.g., method overriding).
Correct Answer: a) Bundling data and methods that operate on that data within a single unit while restricting external access.
Explanation:
Encapsulation protects object state by hiding internal details and exposing controlled public interfaces.
Correct Answer: a) #methodName() {}
Explanation:
Like private fields, private methods are prefixed with `#` and can only be invoked within the class body.
Correct Answer: a) Yes, static private fields and methods can be declared using `static #fieldName` or `static #methodName()`.
Explanation:
ES2022 supports static private members accessed exclusively by static methods within the class.
Correct Answer: a) true
Explanation:
Normal objects are extensible by default, allowing new properties to be added.
Correct Answer: a) Object.seal()
Explanation:
`Object.seal()` seals an object, preventing new properties and deletions while allowing modification of existing writable values.
Correct Answer: a) `Object.freeze()` makes existing properties read-only in addition to sealing structural changes.
Explanation:
Freezing prevents additions, deletions, *and* value changes, whereas sealing only prevents structural additions/deletions.
Correct Answer: a) true
Explanation:
A frozen object is also inherently sealed because sealed objects forbid additions and deletions.
Correct Answer: a) false
Explanation:
A sealed object is not necessarily frozen because its existing properties can still be modified unless explicitly made non-writable.
Correct Answer: a) "Child"
Explanation:
Due to polymorphic dynamic dispatch, when `super()` runs in `Parent`, `this.printName()` invokes `Child`'s overridden `printName`, logging "Child" even though parent constructor ran first.
Correct Answer: a) Object.hasOwn(obj, prop)
Explanation:
`Object.hasOwn()` is the modern ES2022 static replacement for `obj.hasOwnProperty(prop)`.
Correct Answer: a) true
Explanation:
The `in` operator checks both own properties and properties inherited along the prototype chain (found on `Object.prototype`).
Correct Answer: a) false
Explanation:
`Object.hasOwn` checks exclusively for own properties, returning false for inherited properties like `toString`.
Correct Answer: a) It customizes the string returned by `Object.prototype.toString.call(instance)`.
Explanation:
Defining `get [Symbol.toStringTag]() { return 'MyClass'; }` changes the tag output in `[object MyClass]`.
Correct Answer: a) "[object Bar]"
Explanation:
`Symbol.toStringTag` customizes the default object type string representation.
Correct Answer: a) Yes, arrow function class properties lexically bind `this` to the instance, but they exist on each instance rather than the prototype.
Explanation:
Using arrow syntax for class properties binds `this` to the instance upon creation, preventing loss of context during callbacks, but wastes memory as they are not on the prototype.
Correct Answer: a> Explicitly binding them in the constructor using `this.method = this.method.bind(this);` or wrapping them in arrow functions.
Explanation:
Standard methods lose their `this` context when detached as callbacks; binding in the constructor preserves `this` while keeping the method on the prototype.
Correct Answer: a) "function"
Explanation:
Anonymous class expressions evaluate to type "function".
Correct Answer: a) Yes, classes are functions and can be passed as arguments, returned from functions, and assigned to variables.
Explanation:
Because classes are first-class citizens (functions under the hood), they can be passed around dynamically.
Correct Answer: a) A function that takes a superclass and returns a new subclass augmented with additional methods.
Explanation:
Mixin factories allow dynamic composition of inheritance hierarchies in JavaScript (e.g., `const Flyer = (superclass) => class extends superclass { fly() {} }`).
Correct Answer: a) true
Explanation:
`Array.prototype` contains all built-in array methods (`map`, `filter`, `push`, etc.) as its own properties.
Correct Answer: a) To copy enumerable own properties from source objects to a target object (often used for object composition or mixins).
Explanation:
`Object.assign` shallow copies properties, making it useful for composing behaviors onto target instances or prototypes.
Correct Answer: a) The primitive return value is ignored, and the newly created instance is returned.
Explanation:
Constructors ignoring primitive returns ensure the new instance object is always returned correctly.
Correct Answer: a) The returned object overrides the newly created instance completely.
Explanation:
If a constructor explicitly returns an object, that object becomes the return value of the `new` expression, overriding the instance.
Correct Answer: a) It required borrowing constructor via `Parent.call(this)` and manually wiring prototypes via `Child.prototype = Object.create(Parent.prototype)`.
Explanation:
Classical prototypal inheritance setup before ES6 classes required explicit constructor borrowing and prototype chain linking.
Correct Answer: a) Because `Object.create` overwrites the prototype object, resetting its `constructor` property to `Parent`.
Explanation:
Re-assigning the prototype link points `constructor` to `Parent`, so restoring `Child.prototype.constructor = Child` maintains correct metadata.
Correct Answer: a) "function"
Explanation:
`Object` is a built-in constructor function, so `typeof Object` evaluates to "function".
Correct Answer: a) "object"
Explanation:
Prototypes are ordinary objects, so `typeof Object.prototype` evaluates to "object".
Correct Answer: a) Yes, static methods inherit from parent classes and `super` points to the parent class constructor.
Explanation:
Static inheritance allows subclasses to inherit static methods and call them via `super.staticMethod()`.
Correct Answer: a) true
Explanation:
In class inheritance, the child constructor inherits from the parent constructor (`B.__proto__ === A`), enabling static inheritance.
Correct Answer: a) It hides internal implementation details and prevents unauthorized state mutation from outside code.
Explanation:
Encapsulation ensures data integrity by controlling how internal object states are accessed and mutated.
Correct Answer: a) A SyntaxError is thrown during parsing.
Explanation:
Defining more than one `constructor` method in a single ES6 class body triggers an immediate SyntaxError.
Correct Answer: a) Yes, a default constructor is generated automatically for parent and derived classes.
Explanation:
If omitted, JavaScript generates a default constructor (empty for base classes, forwarding arguments and calling `super(...args)` for derived classes).
Correct Answer: a) It prevents any new properties from being added to the object.
Explanation:
`Object.preventExtensions()` locks the object's extensibility so no new properties can be added.
Correct Answer: a) false
Explanation:
Once prevented from extension, `Object.isExtensible` returns false.
Correct Answer: a) Building complex objects by combining simpler, independent objects or behaviors rather than deep class inheritance.
Explanation:
Object composition favors 'has-a' relationships over rigid 'is-a' class inheritance hierarchies.
Correct Answer: a) "function"
Explanation:
Classes in JavaScript are functions under the hood.
Correct Answer: a) Function.prototype
Explanation:
Since classes are functions, their internal prototype (`__proto__`) points to `Function.prototype`.
Correct Answer: a) "[object Null]"
Explanation:
`Object.prototype.toString.call(null)` returns `[object Null]`.
Correct Answer: a) "[object Undefined]"
Explanation:
`Object.prototype.toString.call(undefined)` returns `[object Undefined]`.
Correct Answer: a) Yes, `this` refers to the newly created instance.
Explanation:
Instance field initializers can access `this` and refer to other methods or fields on the instance.
Correct Answer: a) `this` refers to the class constructor function itself.
Explanation:
Inside static initializers or static methods, `this` points to the class constructor.
Correct Answer: a> To control and intercept access or modification of object properties, enabling validation or computed values.
Explanation:
Getters and setters provide a clean property-access interface while executing custom logic behind the scenes.
Correct Answer: a) false
Explanation:
Extending `null` creates a base class whose prototype does not inherit from `Object.prototype`, so `x instanceof Object` evaluates to false.
Correct Answer: a) A class whose prototype object does not inherit from `Object.prototype`.
Explanation:
Extending `null` removes `Object.prototype` from the prototype chain of class instances.
Correct Answer: a) true
Explanation:
Deleting an own property (even a getter) from an ordinary object returns true and removes the property.
Correct Answer: a) true
Explanation:
Classes are functions and all functions evaluate to truthy in boolean contexts.
Correct Answer: a) Decorator pattern
Explanation:
The Decorator pattern dynamically attaches behavior or state to objects wrapping them.
Correct Answer: a) A pattern where an object (subject) maintains a list of dependents (observers) and notifies them of state changes.
Explanation:
The Observer pattern enables publish-subscribe notification mechanisms between decoupled objects.
Correct Answer: a) Yes, using square brackets `[Symbol.iterator]() {}` or `['meth' + 'ods']() {}`.
Explanation:
ES6 classes support computed property names for methods, getters, setters, and fields.
Correct Answer: a) 1
Explanation:
Subclasses inherit static properties and methods from their parent class constructor via prototype delegation on the constructor chain.
Correct Answer: a) A vulnerability where an attacker manipulates `Object.prototype` to inject properties into all objects across an application.
Explanation:
Prototype pollution occurs when insecure recursive merges or assignments allow modifying shared object prototypes.
Correct Answer: a) By freezing `Object.prototype`, using null-prototype objects (`Object.create(null)`), or sanitizing input keys like `__proto__`.
Explanation:
Safeguards against prototype pollution include locking prototypes and filtering special keys like `__proto__`, `constructor`, and `prototype`.
Correct Answer: a) true
Explanation:
`Reflect.has` mirrors the `in` operator, checking prototype inheritance and returning true for `toString`.
Correct Answer: a) ["a"]
Explanation:
`Reflect.ownKeys()` returns all own property keys (string keys and symbols), excluding inherited prototype properties.
Correct Answer: a) 10
Explanation:
JavaScript private fields permit 'same-class' private access, allowing an instance of a class to access private fields of another instance of the same class.
Correct Answer: a) A TypeError is thrown because private fields are strictly scoped to their defining class brand.
Explanation:
Private fields enforce strict branding; accessing them from outside the defining class body or on foreign class instances throws a TypeError.
Correct Answer: a) true
Explanation:
`Array.prototype` inherits directly from `Object.prototype`.
Correct Answer: a) true
Explanation:
`Object.prototype` is the root of the standard prototype chain, so its `__proto__` is `null`.
Correct Answer: a) true
Explanation:
Every class prototype links back to its class constructor via the `constructor` property.
Correct Answer: a) Yes, e.g., `const X = class { constructor() {} };`
Explanation:
Classes can be declared anonymously and assigned to variables or passed as expressions.
Correct Answer: a) "X" (inferred from variable assignment)
Explanation:
JavaScript engines infer class and function names from variable assignments when assigned anonymously.
Correct Answer: a) ""
Explanation:
Unassigned anonymous class expressions have an empty string `name` property.
Related Posts
New
New
New

Python Variables & Data Types MCQs
Variables in Python act as dynamic references reserved in memory to store objects, operating without explicit data type declarations due…
August 27, 2026By MCQs Generator

Latest Python Operators MCQs
Operators in Python are special symbols and keywords used to manipulate data, perform mathematical computations, make boolean comparisons, and control…
August 27, 2026By MCQs Generator

JavaScript Arrays & Array Methods MCQs
JavaScript arrays are dynamic, high-level list-like data structures designed to store ordered collections of data types under a single variable.…
August 29, 2026By MCQs Generator
Related Categories
New












AI & Data Science MCQ
5 topics
By MCQs Generator
New
Arts & Humanities MCQ
4 topics
By MCQs Generator
New
Civil Engineering MCQ
4 topics
By MCQs Generator
New
Commerce & Business MCQ
4 topics
By MCQs Generator
New
Competitive Exams MCQ
5 topics
By MCQs Generator
New
Electrical & Electronics Engineering MCQ
3 topics
By MCQs Generator
New
General Knowledge MCQ
2 topics
By MCQs Generator
New
General Science MCQ
4 topics
By MCQs Generator
New
Law & Judiciary MCQ
3 topics
By MCQs Generator
New
Mechanical Engineering MCQ
4 topics
By MCQs Generator
New
Medical & Health Sciences MCQ
4 topics
By MCQs Generator
New
Modern Tech Fields MCQ
3 topics
By MCQs Generator