Expert Answers

1. (TCO 1) Which of the following would be the most appropriate choice for a method in a Book class? (Points : 5)
Author()
NumberChapters()
Publish()
Language()

2. (TCO 1) Object-oriented programming generally focuses on _____. (Points : 5)
A. separating the interface from the implementation.
B. client side access to implementation details.
C. creating as many classes as possible.
D. code reuse with methods.
All of the above
None of the above
Only A, B, and D

3. (TCO 2) Which of the following components of a class definition do not have a return type? (Points : 5)
Public member functions
Accessor/mutator methods
Private member methods
Destructors
None of the above

5. (TCO 5) Which of the following method pairs are examples of method overloading? (Points : 5)
public void Bake() ; public int Bake(int x)
public int Mix(int x, int y) ; public int Mix(int y, int x)
public int Shake(int x, int y) ; public int Shake(int x, int y, int z)
All of the above
Only A and C

6. (TCO 1) Which of the following statements is/are false? (Points : 5)
The method is the center of the object-oriented paradigm.
The class is a description of one or more entities with a uniform set of attributes (data members) and behaviours (member methods).
Abstraction is the process of ignoring the high level information about a category entity or activity, while concentrating on the “unimportant” details.
None of the above

7. (TCO 2) Assume you implemented a class called Automobile last year. You made sure to design Automobile to include the concept of encapsulation. Now, you need to change the name of one of your private class attributes. Because you used the concept of encapsulation, only the _____ and _____ need to be changed. (Points : 5)
getters; setters
access modifiers; constructors
data type; return values
public attributes; private methods
None of the above

8. (TCO 2) You need to utilize an Item class in your own object-oriented class using composition. Luckily, one of your fellow students just finished writing their own version of an Item class. If the Item class was properly designed as a(n) _____, you do not need to know the specific details of how the class was implemented. Instead, you only need to become familiar with its _____. (Points : 5)
abstract class; abstract methods
object-oriented instance; method implementations
black box system; interface
interface; inheritance hierarchy

9. (TCO 2) Given a private attribute called age, which of the following are proper implementations for a getter and a setter? (Points : 5)
void getAge(){return age}
void setAge(int newAge){age = newAge}
int getAge(){return age}
int setAge(int newAge){return newAge}
int getAge(){age = newAge}
void setAge(int newAge){return age}
int getAge(){return age}
void setName(int newAge){age = newAge

10. (TCO 7) How is the pure virtual function different from a regular function? (Points : 5)
It can only be declared in an abstract class.
It is declared with =0 at the end of the function signature.
It does not contain function implementation.
All of the above

11. (TCO 7) What is an abstract class? (Points : 5)
A generalized class used only to create related derived classes
A class without any superclasses
A class from which we create many instances
Any subclass with more than one superclass

12. (TCO 7) In terms of object-oriented programming, rules for the use of an application programming interface or framework can be enforced through the use of a(n) _____. (Points : 5)
contract
inheritance hierarchy
has-a relationship
object constructed with a multi-arg constructor
All of the above

1. (TCO 4) If you have a complete, working Bicycle class that has been thoroughly tested, and you wish to add an overloaded speedUp() method that can increase the speed of a MountainBike, how should this be accomplished? (Points : 5)
Derive a new MountainBike class from the first Bicycle class.
Add the method to your existing Bicycle class.
Add the method in the same class as the main.
Make a brand new class.

2. (TCO 3) A Ball class and a Baseball class have what type of relationship? (Points : 5)
The Ball is-a Baseball.
The Baseball is-a Ball.
The Ball has-a Baseball
The Baseball has-a Ball.

3. (TCO 4) Why is it a good programming practice not to have too many layers of inherited classes? (Points : 5)
Actually, the more the merrier.
Easy to lose track of the members in the great-grandchildren classes
So that you know which class’s constructor will execute first
None of the above

4. (TCO 4) Suppose class Child is derived from class Parent which in turn is derived from class GrandParent. The class child is a _____ of GrandParent? (Points : 5)
Successor
Forebearer
Ancestor
Descendant
Indirect descendant

5. (TCO 6) What is polymorphism? (Points : 5)
An advanced form of inheritance
A single usefulness for program specificity
One interface may be associated with many implementations
Data hiding

6. (TCO 4) Which of the following is not a good example of a hierarchy that could be modeled with inheritance? (Points : 5)
Person
Even numbers
Bank account
Reptile

7. (TCO 1) Examine the class definition. How many members does it contain?

class clockType
{
public:
void setTime(int, int, int);
void getTime() const;
void icrementSeconds();
void incrementMinutes();
void incrementHours();
private:
int hr;
int min;
int sec;
};
(Points : 5)
8
3
5
None of the above

8. (TCO 7) Which of the following declares a pure virtual function in an abstract C++ class? (Points : 5)
public calculateTip();
public double calculateTip()=0;
public double calculateTip();
public double calculateTip() {}

9. (TCO 4) If the derived class classD overrides a public member function functionName of the base class classB, then to specify a call to that public member function of the base class you use the _____ statement. (Points : 5)
classD::functionName();
classB::functionName();
classD.functionName();
classB.functionName();

10. (TCO 8) Data/information hiding and encapsulation improves construction and maintenance because: (Points : 5)
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

11. (TCO 8) What are some of the characteristics of “self-documenting” code? (Points : 5)
Logical identifier names
Value-added comments
Straightforward algorithms
All of the above
None of the above

12. (TCO 9) Which of the following allow a programmer to reduce the complexity of an object-oriented program? (Points : 5)
Create each class in a separate file
Using namespaces as a container for logically related items
Both A and B
None of the above

1. (TCO 8) Briefly describe which elements of a class use the Camel case, and what are the best practices regarding the naming of these elements. (Points : 18)

2. (TCO 2) Does Encapsulation imply Data/Information Hiding in object-oriented programming? Why or why not? (Points : 18)

3. (TCO 2) Given the following program description,
• identify the required classes/objects necessary to achieve the program requirements;
• briefly describe any relationships that might exist between your classes; and
• briefly describe the overall hierarchy of your proposed classes.

Program Description – You have been asked to create a program designed to keep track of the inventory in a person’s house. The program must keep track of all items owned by the house’s resident and their specific location in the house. A single room can contain any number of items and every item should have a unique ID to differentiate it from all the other items. (Points : 18)

4. (TCO 7) What are the differences between a normal class and an abstract class? Provide an example of an abstract class. (Points : 18)

5. (TCO 4) Consider the class Employee. Given your knowledge of some common components of employees
• show a class hierarchy in which the class Employee inherits from other classes, which, in turn, can also be inherited from yet other classes;
• discuss inheritance from class Employee for other closely related derived classes; and
• discuss the common components of class Employee. (Points : 18)

6. (TCO 3) How does the “has-a” relationship relate to composition? Give an example of such a relationship. (Points : 18)