JavaScript OOP Flashcards

(13 cards)

1
Q

Which term describes the ability of different classes to be treated as instances of the same class through inheritance?

A

Polymorphism

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

Which of the following is the primary mechanism for code reuse in object-oriented JavaScript?

A

Inheritance

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

Which pattern in JavaScript involves creating a single shared instance of a class to be used throughout an application?

A

Singleton

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

How do you call the constructor of a parent class from within a child class in ES6?

A

super()

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

How do you define a getter method inside a JavaScript class?

A

get propertyName() { … }

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

In ES6 and later, which keyword is used to declare a class?

A

class

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

Which of the following best describes encapsulation?

A

Bundling of data and methods that operate on data within a single unit.

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

Which of the following are pillars of object-oriented programming? Select all that apply.

A

Inheritance,

Encapsulation,

Abstraction

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

How can you create a new instance of an object in JavaScript?

A

new instanceName()

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

Which feature of OOP ensures that the internal representation of an object is hidden from the outside?

A

Encapsulation

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

In JavaScript ES6, how can a class inherit from another class?

A

class Child extends Parent {}

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

Which keyword in JavaScript is used to create an object prototype?

A

prototype

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

What is a constructor function in JavaScript?

A

A function that can be called to create an instance of an object.

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