Object Oriented Programming Flashcards

1
Q

What is encapsulation?

A

Two main points:

(1) The idea of data hiding or restricting access to data. You want to be able to keep classes loosely coupled, and only expose data that you want to share with other classes in the system.
(2) To put operations that operate on some data and the data in the same place (i.e., the same class). This is also known as cohesion.

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

What is polymorphism?

A

When classes have different functionality while sharing the same interface. Example: a blue ray player that also plays DVDs. Talk about classes and inheritance.

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

What is composition?

A

Simply, when an object is made up of other types. One object owns the other objects that it is made of. You should mention why it’s preferred over inheritance or how it’s different from aggregation.

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

What is a design pattern?

A

A solution to a common software problem that generally occurs in different situations. It’s a template, rather than a specific implementation. They originated in architecture. Give a common vocabulary that can communicate a large amount of information with a few words.

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

What is a singleton pattern?

A

The heart of this pattern is the idea of restricting the instantiation of a class to a single instance — there can be only one. Talk about how they can often be overused, and can be considered an anti-pattern when used too frequently.

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