Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 1 5 pts (TCO 7) Programmers may be forced to adhere to a contract or a

ID: 2246657 • Letter: Q

Question

Question 1
5 pts
(TCO 7) Programmers may be forced to adhere to a contract or a specification defined by a framework due to the use of _____.

abstract classes

base classes

is-a relationships

None of the above



Question 2
5 pts
(TCO 4) If you have a complete, working Employee class that has been thoroughly tested, and you wish to add an overloaded getSalary() method that can calculate the salary of a Manager which is the total of salary and bonus, how should this be accomplished?

Make a brand new class.

Add the method to your existing Employee class.

Add the method in the same class as the main.

Derive a new Manager class from the first Employee class.

Question 3
5 pts
(TCO 4) In what type(s) of situation(s) would it be best to make a new derived class from a base class?

When your current class is a general form of what your new class should be

When you need to create a specialized class from an existing class

A and B

None of the above



Question 4
5 pts
(TCO 4) Suppose class Child is derived from class Parent which in turn is derived from class GrandParent. When we destroy an object of class Child, three destructors are called: i) Child, ii) Parent, iii) GrandParent. What is the order?

Child, Parent, GrandParent

Parent, GrandParent, Child

GrandParent, Child, Parent

GrandParent, Parent, Child

Question 5
5 pts
(TCO 4) Which of the following is not a good example of a hierarchy that could be modeled with inheritance?

Order

Dog

Animals

Odd numbers



Question 6
5 pts
(TCO 1) Examine the class definition. How many members does it contain?

class clockType
{
public:
void setTime(int, int, int);
void getTime()const;
void printTime() const;
void icrementSeconds();
void incrementMinutes();
void incrementHours();
bool equalTime(const clockType&) const;
private:
int hr;
int min;
int sec;
};

7

3

An average of 5 because (7 + 3) / 2 = 5

10

Question 7
5 pts
(TCO 8) Data/information hiding and encapsulation improves construction and maintenance because:

programs become more self-documenting.

procedural programming practices are supported.

adding additional details is isolated to a single class.

All of the above

None of the above



Question 8
5 pts
(TCO 8) What are some of the characteristics of "self-documenting" code?

Detailed comments, addressing all aspects of the code

Deep levels of nesting to ensure all situations are addressed

Straightforward algorithms

All of the above

None of the above



Question 9
5 pts
(TCO 9) Which of the following allow a programmer to reduce the complexity of an object-oriented program?

Create each class in a separate file

Using namespaces as a container for logically related items

Using namespace to create global types

All of the above

Explanation / Answer

1.

Ans : Abstract Classes.

Reason: An abstract class can never be instantiated. Considering the translation between the code design and the real-world concept or situation, abstract classes are much better.

Eg: Lets say class Animal as abstract class.In real life you can never have an instance of an Animal as it makes no sense at all as you can't just create an Animal, you create an Animal, such as a Cat or Dog as they are real-world entities.

2.

Ans: Derive a new Manager class from the first Employee class.

Reason: Every manager is an Employee but every employee is not a manager. So, create a new Manager class and overload the getSalary() method to calculate the salary of a manager.

3.

Ans : A and B

Reason: We can use the common properties of the base class and a dervied class which needs some additional properties along with the common properties can inherit from the base class.

4.

Ans: Child parent grandparent.

Reason: Trivial(That's how the constructors work).

5.

Ans: Dog.

Reason: Dog cannot be inherited further. Animals can be inherited further and also Odd numbers can also be classified as prime and non-prime.

6.

Ans :10

Reason: All the private and public variables/methods are called members of the class

7.

Ans: adding additional details is isolated to a single class.

Reason:  Encapsulation promotes maintenance because code changes can be made independently without effecting other classes.

8.

Ans: All the above.

Reason: Characteristics of a self-documenting code.

9.

Ans: Using namespaces as a container for logically related item

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote