Chapter 1 (Quiz 2) Flashcards

(16 cards)

1
Q

What are the 2 principals of Software Engineering?

A

1 - High Cohesion.
2 - Low Coupling.

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

What is the difference between High & Low Cohesion?

A

High Cohesion : The module does one thing well.
Low Cohesion : The module does many unrelated things.

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

What is the difference between Low & High Coupling?

A

Low Coupling : Modules are independent and interact through well-defined interfaces.
High Coupling : Modules are tightly bound; changes in one can break the other.

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

What type of Cohesion & Coupling does this code have?

A

We have High Cohesion & Low Coupling.

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

What type of Cohesion & Coupling does this code have?

A

We have Low Cohesion & High Coupling.

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

What type of Cohesion & Coupling does this code have?

A

We have Low Cohesion & Low Coupling.

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

What type of Cohesion & Coupling does this code have?

A

We have High Cohesion & High Coupling.

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

Why would we use Inheritance?

A

It helps us avoid code duplication, saves time, and makes error fixing easier across related classes.

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

What are the types of inheritance access in C++?

A

1 - Public: everything stays the same (except private isn’t inherited).
2 - Protected: public becomes protected and protected stays protected; private not inherited.
3 - Private: everything becomes private; private is not inherited.

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

Will this code work? if not why?

A

It won’t work because it leads to the diamond problem, causing ambiguity.
We need to add “Virtual”!

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

Would this code work and have an output? (1)

A

Yes, because the inheritance is public, everything stays the same, except private isn’t inherited.

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

Would this code work and have an output? (2)

A

No, because the inheritance is Protected, public becomes protected and protected stays protected; private not inherited.

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

Would this code work and have an output? (3)

A

No, because the inheritance is private, everything becomes private; private is not inherited.

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

Would this code work and have an output? (4)

A

Yes, because we use a get method. ( myRecipe() ).

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

Would this code work and have an output? (5)

A

No, because both Father & Mother privately inherit from GrandFather, so Son doesn’t inherit Chocolate_Recipe from them.

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

What is a Pointer?

A

A special variable whose value is the address of another variable in memory.