Chapter 1 (Quiz 2) Flashcards
(16 cards)
What are the 2 principals of Software Engineering?
1 - High Cohesion.
2 - Low Coupling.
What is the difference between High & Low Cohesion?
High Cohesion : The module does one thing well.
Low Cohesion : The module does many unrelated things.
What is the difference between Low & High Coupling?
Low Coupling : Modules are independent and interact through well-defined interfaces.
High Coupling : Modules are tightly bound; changes in one can break the other.
What type of Cohesion & Coupling does this code have?
We have High Cohesion & Low Coupling.
What type of Cohesion & Coupling does this code have?
We have Low Cohesion & High Coupling.
What type of Cohesion & Coupling does this code have?
We have Low Cohesion & Low Coupling.
What type of Cohesion & Coupling does this code have?
We have High Cohesion & High Coupling.
Why would we use Inheritance?
It helps us avoid code duplication, saves time, and makes error fixing easier across related classes.
What are the types of inheritance access in C++?
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.
Will this code work? if not why?
It won’t work because it leads to the diamond problem, causing ambiguity.
We need to add “Virtual”!
Would this code work and have an output? (1)
Yes, because the inheritance is public, everything stays the same, except private isn’t inherited.
Would this code work and have an output? (2)
No, because the inheritance is Protected, public becomes protected and protected stays protected; private not inherited.
Would this code work and have an output? (3)
No, because the inheritance is private, everything becomes private; private is not inherited.
Would this code work and have an output? (4)
Yes, because we use a get method. ( myRecipe() ).
Would this code work and have an output? (5)
No, because both Father & Mother privately inherit from GrandFather, so Son doesn’t inherit Chocolate_Recipe from them.
What is a Pointer?
A special variable whose value is the address of another variable in memory.