JavaScript MCQs – Object-oriented programming is essential for mastering advanced programming concepts. Topics like classes, inheritance, encapsulation, polymorphism, and prototypes are fundamental in creating reusable, maintainable code. Understanding this, constructors, method overriding, and static methods is vital for interviews. Practicing MCQs helps in reinforcing concepts and prepares you to handle scenario-based questions confidently.
1.) What is an object in JavaScript?
A) A collection of key-value pairs
B) A special type of function
C) A built-in data type
D) None of the above
2.) How do you create an object using the constructor function?
A) let obj = {};
B) let obj = []
C) let obj = Object.create();
D) let obj = new Object();
3.) What does the this
keyword represent inside an object method?
A) The global object
B) The object that owns the method
C) The parent object
D) Undefined
4.) What is a class in JavaScript?
A) A template for creating objects
B) A function that returns an object
C) A built-in data type
D) An array-like structure
5.) Which keyword is used to define a class in JavaScript?
A) define
B) new
C) class
D) object
6.) What is the purpose of Object.getPrototypeOf()?
A) To create a prototype for an object
B) To retrieve the prototype of an object
C) To modify an object’s prototype
D) To seal an object
7.) What is the purpose of a constructor in a class?
A) To define methods
B) To destroy an object
C) To inherit another class
D) To initialize properties when an object is created
8.) What is inheritance in JavaScript?
A) Copying one object to another
B) Using multiple objects together
C) Defining methods in an object
D) A class receiving properties and methods from another class
9.) How do you call the parent class constructor in a subclass?
A) super();
B) parent();
C) constructor();
D) base();
10.) What is the prototype in JavaScript?
A) A method for copying objects
B) A mechanism to inherit properties and methods
C) A way to destroy objects
D) A keyword for creating objects
Related