Object-Oriented Programming Flashcards

1
Q

What is NOT considered object-oriented?

A

public data, multiple inheritance, setters/getters, protected or private derivation, friends (excluding operator overloading), spontaneous change to an object’s state

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

What kind of relationships are there? Describe them.

A

Contained (“has a”) relationships, using (user awareness), and inheritance/specialized (“Is a”)

Contained: One class contains the object of another class as a data member. 
Using: Passing the instance of one type as a pointer or reference of another type in a member function argument. 
Inheritance: Where child class(es) are derived from a parent/base class and the child IS the parent + more.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the object’s “state”?

Can the object’s state change?

A

The object’s state is the collection of all the information held by an object.

A mutable object’s state can change over time, but not spontaneously. The change in the object’s state must be a consequence of methods performed on the object. An immutable object cannot change its state.

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

What are the “rules” of object-oriented programming?

A
  1. Each object has narrow and specific responsibilities.
  2. Objects can store data based on prior operations.
  3. No public data.
  4. An object has a “state”, “operations”, and an “identity”.
  5. Two or more classes can have the same state and operations but a separate identity.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the four parts of object-oriented design?

A
  1. Understand the problem from an application perspective.
  2. List all nouns relevant to the problem.
  3. Group the nouns together and push up the common.
  4. Make sure the classes communicate to work together to solve the problem.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

To avoid having the state of an object spontaneously change, what do you need to do?

A

Keep the data in the private or protected sections.

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

What IS considered object-oriented?

A

Single inheritance, classes have clear responsibilities but are not bloated, public derivation, private or protected data

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