OOP Flashcards

1
Q

What are objects?

A

Objects are a collections of variable and functions

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

What are variable presents in object called?

A

Properties

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

What are function present in an object called?

A

Methods

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

What is OOP?

A

Object Oriented Programming is a set of rules to structure our code so that it makes it easy to

  • add new stuff and make changes
  • read through
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is encapsulation?

A

The process of storing functions (methods) with their associated data (properties) in one thing (object)

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

Why is encapsulation important?

A
  • make code readable

- it is easy to make changes

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

What is abstraction?

A

It is all about hide details and showing the essentials

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

Why is abstraction important in OOP?

A

Because it enables us to make small more manageable pieces of code

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

What is it used if you want to make a lot of objects

A

a constructor

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

By changing the property (this.) to variable (let) what do we achieve?

A

we make sure they are not bound to the object and achieve abstraction, since they are not longer visible to the user

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

What is inheritance?

A

It a pillar of OOP, which consist of make a class from another class for a hierarchy of classes that share a set of properties and methods

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

When you see a property for e.g (_name) what does it mean?

A

It is a convention that means to not to change that property

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

Why is it important to have “private property” that can’t be changed outside the class?

A

It is the mechanism that allow us to keep abstraction in our code. (remove the possibility of shooting yourself in the foot)

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

this._name plus a get name() method what does allow us to achieve?

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

Why is inheritance important?

A

Because it helps us to eliminate redundant code and keep our code DRY

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

What is Inheritance?

A

The ability for a class to share a set of properties and method to his child

17
Q

What is polymorphism?

A

Is the ability of code written to use an interface to work with any number of objects that provide that interface

18
Q

Why do we need polymorphism?

A

It helps us to avoid if/else that we would have to keep track of