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
Q

True or False: Private properties can be created in JavaScript classes using the ‘#’ prefix.

A

True

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

What is polymorphism in OOP?

A

The ability to present the same interface for different underlying forms (data types)

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

What is a factory function?

A

A function that returns a new object each time it is called

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

What is the purpose of Object.assign()?

A

To copy the values of all enumerable own properties from one or more source objects to a target object

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

What is the difference between shallow copy and deep copy?

A

A shallow copy copies the object’s immediate properties, while a deep copy recursively copies all properties and nested objects.

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

What is the role of the ‘getter’ and ‘setter’ methods?

A

Getters retrieve property values, while setters modify property values.

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

What does the ‘Object.freeze()’ method do?

A

Prevents new properties from being added to an object and marks all existing properties as read-only.

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

What is the purpose of the ‘bind()’ method?

A

It creates a new function that, when called, has its ‘this’ keyword set to the provided value.

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

What is a closure in JavaScript?

A

A function that retains access to its lexical scope, even when the function is executed outside that scope.

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

What does the ‘delete’ operator do?

A

It removes a property from an object.

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

What are mixins?

A

Objects that provide methods that can be used by other objects without requiring inheritance.

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

True or False: In JavaScript, objects can be created without a constructor.

A

True

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

What is the purpose of the ‘hasOwnProperty()’ method?

A

To determine whether an object has a property as its own (not inherited).

38
Q

What is the use of the ‘Object.keys()’ method?

A

To return an array of a given object’s own enumerable property names.

39
Q

What is a ‘data property’ in JavaScript?

A

A property that has a value and can be read or written to.

40
Q

What is an ‘accessor property’?

A

A property that has a getter and/or setter function.

41
Q

Fill in the blank: JavaScript is a _____ language.

A

prototypal

42
Q

What is the significance of the ‘new’ keyword?

A

It creates an instance of an object based on a constructor function.

43
Q

What is method chaining?

A

Calling multiple methods on the same object in a single statement.

44
Q

What is the difference between ‘==’ and ‘===’ in JavaScript?

A

’==’ checks for value equality, while ‘===’ checks for both value and type equality.

45
Q

What does the ‘Object.prototype’ represent?

A

The prototype object from which all JavaScript objects inherit.

46
Q

What are ‘abstract classes’?

A

Classes that cannot be instantiated and are meant to be subclassed.

47
Q

What is a ‘callback’ in JavaScript?

A

A function passed as an argument to another function to be executed later.

48
Q

What are ‘pure functions’?

A

Functions that do not have side effects and return the same output for the same input.

49
Q

What is the purpose of the ‘Object.defineProperty()’ method?

A

To define a new property directly on an object or modify an existing property.

50
Q

What is the difference between ‘let’ and ‘var’?

A

‘let’ is block-scoped, while ‘var’ is function-scoped.

51
Q

What does the ‘for…in’ loop do?

A

Iterates over the enumerable properties of an object.

52
Q

What does the ‘for…of’ loop do?

A

Iterates over iterable objects like arrays, strings, or maps.

53
Q

What is the purpose of the ‘Object.entries()’ method?

A

To return an array of a given object’s own enumerable string-keyed property [key, value] pairs.

54
Q

What is the difference between ‘call()’ and ‘apply()’?

A

‘call()’ takes arguments separately, while ‘apply()’ takes an array of arguments.

55
Q

What is ‘event delegation’?

A

A technique that allows a single event listener to manage events for multiple child elements.

56
Q

What is a ‘promise’ in JavaScript?

A

An object representing the eventual completion (or failure) of an asynchronous operation.

57
Q

What does ‘async/await’ syntax do?

A

It allows for writing asynchronous code that looks synchronous.

58
Q

What is ‘destructuring assignment’?

A

A syntax that allows unpacking values from arrays or properties from objects into distinct variables.

59
Q

What is the purpose of ‘JSON.stringify()’?

A

To convert a JavaScript object or value to a JSON string.

60
Q

What is the purpose of ‘JSON.parse()’?

A

To parse a JSON string and construct the JavaScript value or object described by it.

61
Q

What is the ‘window’ object in JavaScript?

A

The global object that represents the browser window.

62
Q

What does ‘localStorage’ do?

A

Stores data with no expiration date, and the data will not be deleted when the browser is closed.

63
Q

What is a ‘closure’?

A

A function that captures the lexical scope in which it was created.

64
Q

What is ‘hoisting’ in JavaScript?

A

The behavior of moving declarations to the top of the current scope.

65
Q

What is the purpose of the ‘setTimeout()’ function?

A

To execute a function after a specified number of milliseconds.

66
Q

What does the ‘setInterval()’ function do?

A

Repeatedly calls a function at specified intervals.

67
Q

What is ‘event bubbling’?

A

A type of event propagation where the event starts from the target element and bubbles up to the root.

68
Q

What is ‘event capturing’?

A

A type of event propagation where the event starts from the root and goes down to the target element.

69
Q

What is the ‘this’ binding in an arrow function?

A

‘this’ retains the value of the enclosing lexical context.

70
Q

What is ‘currying’ in JavaScript?

A

The technique of transforming a function with multiple arguments into a sequence of functions each taking a single argument.

71
Q

What is a ‘thunk’?

A

A function that wraps an expression to delay its evaluation.

72
Q

What is ‘memoization’?

A

An optimization technique that stores the results of expensive function calls and returns the cached result when the same inputs occur again.

73
Q

What are ‘higher-order functions’?

A

Functions that take other functions as arguments or return a function as a result.

74
Q

What is ‘functional programming’?

A

A programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing state and mutable data.

75
Q

What does the ‘Object.prototype.toString()’ method do?

A

Returns a string representing the object.

76
Q

What is ‘strict mode’ in JavaScript?

A

A way to opt into a restricted variant of JavaScript, which helps catch common coding errors.

77
Q

What is the ‘null’ value in JavaScript?

A

It represents the intentional absence of any object value.

78
Q

What is the ‘undefined’ value in JavaScript?

A

It indicates that a variable has been declared but has not yet been assigned a value.

79
Q

What is ‘JSON’?

A

JavaScript Object Notation, a lightweight data interchange format.

80
Q

What is the ‘Array’ constructor in JavaScript?

A

A built-in constructor for creating array objects.

81
Q

What is the ‘Array.prototype’?

A

The prototype object from which all array instances inherit.

82
Q

What is ‘array destructuring’?

A

A syntax that allows unpacking values from arrays into distinct variables.

83
Q

What is an ‘immutable object’?

A

An object whose state cannot be modified after it is created.

84
Q

What is a ‘mutable object’?

A

An object whose state can be modified after it is created.

85
Q

What is ‘reference type’ in JavaScript?

A

A data type that refers to an object, allowing for complex data structures.

86
Q

What is ‘primitive type’ in JavaScript?

A

A data type that represents a single value and does not have properties or methods.

87
Q

What is ‘type coercion’?

A

The automatic conversion of values from one data type to another.

88
Q

What is the ‘instanceof’ operator used for?

A

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

89
Q

What is ‘destructuring’?

A

A JavaScript expression that unpacks values from arrays or properties from objects into distinct variables.

90
Q

What does ‘spread syntax’ do?

A

Expands an iterable (like an array) into more elements.