OOP Flashcards

1
Q

Why do we need OOP

A

OOP helps us to think in terms of real world objects. For example you can Have a person and store his name age and address simply in the object.

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

What are the important pillars in OOP

A

Abstraction which is to show only what is necessary. Polymorphism which is where the object acts differently under different conditions, for example if you had an employee who changed from a user to an admin. Inheritance which is where you have a parent child relationship where you have something in common in the parent and the child can inherit it, for example you could have a class cars that has a property of colors and there child could be a type of car which as well would then need to have colors also. Encapsulation which means to hide complexity.

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

What is a class and an object

A

A class is a blueprint or a type which to create you need to make an instance of a class which will be an object and will have properties and methods.

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

Difference between Abstraction and Encapsulation

A

Abstraction happens during the design phase and decide what has to be shown public where as during the execution phase the developer uses encapsulation to implement the thought process of abstraction.

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

What is inheritance

A

A way to pass down properties and methods in classes from parent to child. (extend) keyword to become a child of parent

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

What is overloading

A

In the same class you can have the same method names with different parameters.

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

What is overriding

A

A way to change the logic of a function from a parent that was passed to a child. (super) keyword to allow overriding of parent function but not replacing.

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

What is polymorphism

A

An ability of an object to act differently under different conditions. Polymorphism cannot be implemented without inheritance.

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

What is polymorphism

A

An ability of an object to act differently under different conditions. Polymorphism cannot be implemented without inheritance.

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

Why do you need abstract classes

A

It is a half defined parent class where some methods are defined and others are left undefined to be handled by the child classes. You cannot create instances of an abstract class.

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

What is encapsulation

A

Storing all variables and functions inside of an object to keep things organized. Benefits would be function have less parameters due to properties being nested in object and better than procedural programming where you have a bunch of function everywhere and can cause problems when having to change things.

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

What is abstraction

A

Through the process of abstraction, a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency.

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