OOP Flashcards

1
Q

What does OOP stand for?

A

Object-Oriented Programming

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False: In JavaScript, functions are first-class objects.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What keyword is used to create a new object in JavaScript?

A

new

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Fill in the blank: In JavaScript, a _____ is a blueprint for creating objects.

A

constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What method is used to create an object from a constructor function?

A

The ‘new’ keyword

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the purpose of the ‘this’ keyword in JavaScript?

A

‘this’ refers to the current object context

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

True or False: JavaScript supports multiple inheritance.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a prototype in JavaScript?

A

An object from which other objects inherit properties

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What method can be used to set the prototype of an object?

A

Object.create()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is encapsulation in OOP?

A

The bundling of data and methods that operate on that data within one unit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is inheritance in JavaScript OOP?

A

The mechanism by which one object can inherit properties and methods from another object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Fill in the blank: A _____ is a property or method that can be accessed from an instance of an object.

A

member

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the main advantage of using OOP?

A

Improved modularity and code reusability

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is method overriding?

A

When a subclass provides a specific implementation of a method that is already defined in its superclass

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

True or False: All JavaScript objects inherit from Object.prototype.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the purpose of the ‘instanceof’ operator?

A

To check if an object is an instance of a specific constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is a class in JavaScript?

A

A syntactical sugar over JavaScript’s existing prototype-based inheritance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How do you define a class in JavaScript?

A

Using the ‘class’ keyword

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What keyword is used to extend a class?

A

extends

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is the constructor method in a class?

A

A special method for creating and initializing an object created with a class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is the purpose of the ‘super’ keyword?

A

To call the constructor of a parent class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Fill in the blank: A _____ is a function associated with an object.

A

method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What does the ‘static’ keyword do in a class?

A

Defines a method or property that belongs to the class itself rather than instances of the class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is a singleton in JavaScript?

A

A design pattern that restricts the instantiation of a class to a single instance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
True or False: Private properties can be created in JavaScript classes using the '#' prefix.
True
26
What is polymorphism in OOP?
The ability to present the same interface for different underlying forms (data types)
27
What is a factory function?
A function that returns a new object each time it is called
28
What is the purpose of Object.assign()?
To copy the values of all enumerable own properties from one or more source objects to a target object
29
What is the difference between shallow copy and deep copy?
A shallow copy copies the object's immediate properties, while a deep copy recursively copies all properties and nested objects.
30
What is the role of the 'getter' and 'setter' methods?
Getters retrieve property values, while setters modify property values.
31
What does the 'Object.freeze()' method do?
Prevents new properties from being added to an object and marks all existing properties as read-only.
32
What is the purpose of the 'bind()' method?
It creates a new function that, when called, has its 'this' keyword set to the provided value.
33
What is a closure in JavaScript?
A function that retains access to its lexical scope, even when the function is executed outside that scope.
34
What does the 'delete' operator do?
It removes a property from an object.
35
What are mixins?
Objects that provide methods that can be used by other objects without requiring inheritance.
36
True or False: In JavaScript, objects can be created without a constructor.
True
37
What is the purpose of the 'hasOwnProperty()' method?
To determine whether an object has a property as its own (not inherited).
38
What is the use of the 'Object.keys()' method?
To return an array of a given object's own enumerable property names.
39
What is a 'data property' in JavaScript?
A property that has a value and can be read or written to.
40
What is an 'accessor property'?
A property that has a getter and/or setter function.
41
Fill in the blank: JavaScript is a _____ language.
prototypal
42
What is the significance of the 'new' keyword?
It creates an instance of an object based on a constructor function.
43
What is method chaining?
Calling multiple methods on the same object in a single statement.
44
What is the difference between '==' and '===' in JavaScript?
'==' checks for value equality, while '===' checks for both value and type equality.
45
What does the 'Object.prototype' represent?
The prototype object from which all JavaScript objects inherit.
46
What are 'abstract classes'?
Classes that cannot be instantiated and are meant to be subclassed.
47
What is a 'callback' in JavaScript?
A function passed as an argument to another function to be executed later.
48
What are 'pure functions'?
Functions that do not have side effects and return the same output for the same input.
49
What is the purpose of the 'Object.defineProperty()' method?
To define a new property directly on an object or modify an existing property.
50
What is the difference between 'let' and 'var'?
'let' is block-scoped, while 'var' is function-scoped.
51
What does the 'for...in' loop do?
Iterates over the enumerable properties of an object.
52
What does the 'for...of' loop do?
Iterates over iterable objects like arrays, strings, or maps.
53
What is the purpose of the 'Object.entries()' method?
To return an array of a given object's own enumerable string-keyed property [key, value] pairs.
54
What is the difference between 'call()' and 'apply()'?
'call()' takes arguments separately, while 'apply()' takes an array of arguments.
55
What is 'event delegation'?
A technique that allows a single event listener to manage events for multiple child elements.
56
What is a 'promise' in JavaScript?
An object representing the eventual completion (or failure) of an asynchronous operation.
57
What does 'async/await' syntax do?
It allows for writing asynchronous code that looks synchronous.
58
What is 'destructuring assignment'?
A syntax that allows unpacking values from arrays or properties from objects into distinct variables.
59
What is the purpose of 'JSON.stringify()'?
To convert a JavaScript object or value to a JSON string.
60
What is the purpose of 'JSON.parse()'?
To parse a JSON string and construct the JavaScript value or object described by it.
61
What is the 'window' object in JavaScript?
The global object that represents the browser window.
62
What does 'localStorage' do?
Stores data with no expiration date, and the data will not be deleted when the browser is closed.
63
What is a 'closure'?
A function that captures the lexical scope in which it was created.
64
What is 'hoisting' in JavaScript?
The behavior of moving declarations to the top of the current scope.
65
What is the purpose of the 'setTimeout()' function?
To execute a function after a specified number of milliseconds.
66
What does the 'setInterval()' function do?
Repeatedly calls a function at specified intervals.
67
What is 'event bubbling'?
A type of event propagation where the event starts from the target element and bubbles up to the root.
68
What is 'event capturing'?
A type of event propagation where the event starts from the root and goes down to the target element.
69
What is the 'this' binding in an arrow function?
'this' retains the value of the enclosing lexical context.
70
What is 'currying' in JavaScript?
The technique of transforming a function with multiple arguments into a sequence of functions each taking a single argument.
71
What is a 'thunk'?
A function that wraps an expression to delay its evaluation.
72
What is 'memoization'?
An optimization technique that stores the results of expensive function calls and returns the cached result when the same inputs occur again.
73
What are 'higher-order functions'?
Functions that take other functions as arguments or return a function as a result.
74
What is 'functional programming'?
A programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing state and mutable data.
75
What does the 'Object.prototype.toString()' method do?
Returns a string representing the object.
76
What is 'strict mode' in JavaScript?
A way to opt into a restricted variant of JavaScript, which helps catch common coding errors.
77
What is the 'null' value in JavaScript?
It represents the intentional absence of any object value.
78
What is the 'undefined' value in JavaScript?
It indicates that a variable has been declared but has not yet been assigned a value.
79
What is 'JSON'?
JavaScript Object Notation, a lightweight data interchange format.
80
What is the 'Array' constructor in JavaScript?
A built-in constructor for creating array objects.
81
What is the 'Array.prototype'?
The prototype object from which all array instances inherit.
82
What is 'array destructuring'?
A syntax that allows unpacking values from arrays into distinct variables.
83
What is an 'immutable object'?
An object whose state cannot be modified after it is created.
84
What is a 'mutable object'?
An object whose state can be modified after it is created.
85
What is 'reference type' in JavaScript?
A data type that refers to an object, allowing for complex data structures.
86
What is 'primitive type' in JavaScript?
A data type that represents a single value and does not have properties or methods.
87
What is 'type coercion'?
The automatic conversion of values from one data type to another.
88
What is the 'instanceof' operator used for?
To check if an object is an instance of a specific constructor.
89
What is 'destructuring'?
A JavaScript expression that unpacks values from arrays or properties from objects into distinct variables.
90
What does 'spread syntax' do?
Expands an iterable (like an array) into more elements.