OOP Flashcards
What does OOP stand for?
Object-Oriented Programming
True or False: In JavaScript, functions are first-class objects.
True
What keyword is used to create a new object in JavaScript?
new
Fill in the blank: In JavaScript, a _____ is a blueprint for creating objects.
constructor
What method is used to create an object from a constructor function?
The ‘new’ keyword
What is the purpose of the ‘this’ keyword in JavaScript?
‘this’ refers to the current object context
True or False: JavaScript supports multiple inheritance.
False
What is a prototype in JavaScript?
An object from which other objects inherit properties
What method can be used to set the prototype of an object?
Object.create()
What is encapsulation in OOP?
The bundling of data and methods that operate on that data within one unit
What is inheritance in JavaScript OOP?
The mechanism by which one object can inherit properties and methods from another object
Fill in the blank: A _____ is a property or method that can be accessed from an instance of an object.
member
What is the main advantage of using OOP?
Improved modularity and code reusability
What is method overriding?
When a subclass provides a specific implementation of a method that is already defined in its superclass
True or False: All JavaScript objects inherit from Object.prototype.
True
What is the purpose of the ‘instanceof’ operator?
To check if an object is an instance of a specific constructor
What is a class in JavaScript?
A syntactical sugar over JavaScript’s existing prototype-based inheritance
How do you define a class in JavaScript?
Using the ‘class’ keyword
What keyword is used to extend a class?
extends
What is the constructor method in a class?
A special method for creating and initializing an object created with a class
What is the purpose of the ‘super’ keyword?
To call the constructor of a parent class
Fill in the blank: A _____ is a function associated with an object.
method
What does the ‘static’ keyword do in a class?
Defines a method or property that belongs to the class itself rather than instances of the class
What is a singleton in JavaScript?
A design pattern that restricts the instantiation of a class to a single instance