11.) What does Object.create() do?
A) Copies an object
B) Creates a deep clone of an object
C) Creates a new object with the specified prototype
D) Returns a stringified version of an object
12.) What does encapsulation mean in JavaScript?
A) Hiding data and exposing only the necessary parts of an object
B) Combining multiple objects into one
C) Creating a copy of an object
D) Removing methods from an object
13.) What does the static keyword do in a class?
A) Defines a method accessible only on the class itself, not instances
B) Makes a property immutable
C) Creates a constant variable
D) Creates an instance of a class
14.) How do you define a private field in a class?
A) Using _ as a prefix
B) Using the private keyword
C) Using # as a prefix
D) Using const
15.) What is method overriding in JavaScript?
A) Defining multiple methods with the same name
B) A subclass providing its own implementation of a method inherited from a parent class
C) Changing the return type of a method
D) Calling a method multiple times
16.) What is the purpose of Object.freeze()?
A) To make an object immutable
B) To create a prototype
C) To inherit properties
D) To delete an object
17.) What does the instanceof
operator do in JavaScript?
A) Defines a property in a class
B) Creates an instance of a class
C) Checks if a class has been inherited
D) Checks if an object was created by a specific class
18.) What is polymorphism in JavaScript?
A) Having multiple methods with the same name but different implementations
B) Creating multiple instances of a class
C) Inheriting properties from multiple classes
D) None of the above
19.) How do you check if a property exists in an object?
A) obj.hasOwnProperty(property)
B) obj.property
C) property in obj
D) Both A and C
20.) What is the difference between call() and apply() methods in JavaScript?
A) call() accepts arguments as an array, apply() as separate arguments.
B) apply() accepts arguments as an array, call() as separate arguments.
C) Both are used to create new objects.
D) Both are the same in functionality.
Related