Object Oriented Programming Flashcards

1
Q

Encapsulation

A

Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism that binds together code and the data it manipulates. In Encapsulation, the variables or data of a class are hidden from any other class and can be accessed only through any member function of their class in which they are declared. As in encapsulation, the data in a class is hidden from other classes, so it is also known as data-hiding.

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

Inheritance

A

Inheritance is an important pillar of OOP(Object-Oriented Programming). The capability of a class to derive properties and characteristics from another class is called Inheritance. When we write a class, we inherit properties from other classes. So when we create a class, we do not need to write all the properties and functions again and again, as these can be inherited from another class that possesses it. Inheritance allows the user to reuse the code whenever possible and reduce its redundancy.

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

Polymorphism

A

The word polymorphism means having many forms. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form. For example, A person at the same time can have different characteristics. Like a man at the same time is a father, a husband, an employee. So the same person posses different behavior in different situations. This is called polymorphism.

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

Dynamic Binding

A

In dynamic binding, the code to be executed in response to the function call is decided at runtime. Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run time. Dynamic Method Binding One of the main advantages of inheritance is that some derived class D has all the members of its base class B. Once D is not hiding any of the public members of B, then an object of D can represent B in any context where a B could be used. This feature is known as subtype polymorphism.

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

SOLID

A

Single-Responsibility Principle
Open-Closed Principle
Liskov Substitution Principle
Interface Segregation Principle
Dependency Inversion

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

Single-Responsibility Principle

A

A class should have one and only one reason to change, meaning that a class should have only one job.

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

Open-Closed Principle

A

Objects or entities should be open for extension but closed for modification.

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

Interface Segregation Principle

A

A client should never be forced to implement an interface that it doesn’t use, or clients shouldn’t be forced to depend on methods they do not use.

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

Dependency Inversion Principle

A

Entities must depend on abstractions, not on concretions. It states that the high-level module must not depend on the low-level module, but they should depend on abstractions.

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