$25
Question 1.1. (TCO 1) Object-oriented programming does not generally focus on _____. (Points : 5)
A. data abstraction
B. cutting down on the lines of code
C. client side access to implementation details
D. information hiding
All of the above
None of the above
Only B and C
Question 2.2. (TCO 2) Which of the following class components do not have an access modifier? (Points : 5)
Constructors
Destructors
State variables
All of the above
None of the above
Question 3.3. (TCO 5) Which of the following method pairs are examples of method overloading? (Points : 5)
public void Dance() ; public int Dance(int x)
public int Walk(int x, int y) ; public void Walk(int x, int y, int z)
public int Jump(int x, int y) ; public int Jump(int y, int x)
All of the above
Only A and B
Question 4.4. (TCO 1) Which of the following statements is/are true? (Points : 5)
You can create sub-classes and sub-objects.
By using the keyword class in your program, memory is allocated for the object being defined.
In object-oriented programming we design the program as a set of cooperating methods.
None of the above
Question 5.5. (TCO 1) Which of the following would be a more appropriate choice for a method in a Computer class? (Points : 5)
MonitorSize()
Reboot()
ProcessorType()
Keyboard()
Question 6.6. (TCO 2) Which of the following statements is/are true? (Points : 5)
A. In general, reusable classes tend to have interfaces that are more concrete than abstract.
B. There are three types of attributes: local, object and class attributes.
C. A static method of a class can access non static members of the class directly.
All of the above
Only A and C
Question 7.7. (TCO 2) You need to utilize a Plant class in your own object-oriented class using composition. Luckily, one of your fellow students just finished writing their own version of a Plant class. If the Plant class was properly designed as a black box, which of the following statements are false? (Points : 5)
All of the required inputs will be revealed to you.
All of the outputs will be revealed to you.
Only the implementation details will be revealed to you.
Only the interface details will be revealed to you.
Question 8.8. (TCO 2) A class is designed with three public attributes: attributeOne, attributeTwo and attributeThree. attributeOne is an integer data type, attributeTwo is a double data type and attributeThree is a string data type. Which pseudocode representation(s) of getters would be appropriate for this class? (Points : 5)
int getAttributeOne()
{
return attributeOne
}
string getAttributeTwo()
{
return attributeTwo
}
int getAttributeThree(int newAttributeThree)
{
attributeThree = newAttributeThree
}
void getAttributeTwo()
{
return attributeOne
}
Both A and D
None of the above
Question 9.9. (TCO 2) You have been tasked to create an EntertainmentSystem class and your boss wants you to consider the concept of encapsulation as you design your class. Which of the following actions will you take? (Points : 5)
Declare a single no-arg constructor in order to prevent outside entities from initializing the state of a new EntertainmentSystem object.
Combine attributes and behaviors specific to an EntertainmentSystem together into one cohesive unit.
Declare the class as static so that only one instance of an EntertainmentSystem can be used at a time.
Declare the class as private.
All of the above
Question 10.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
Question 11.11. (TCO 7) What is an abstract class? (Points : 5)
Any class which can be instantiated
A class without any subclasses
A conceptually vague or generalized class
Any superclass with more than one subclass
Question 12.12. (TCO 7) When developing an object-oriented application, developers are required to comply with specific _____ or rules defined in a framework. (Points : 5)
object instantiations
naming conventions
instantiated classes
contracts
All of the above
Page 2
Question 1.1. (TCO 4) Select the false statement regarding inheritance. (Points : 5)
A child class can have more functionality than the parent class.
A child class can itself be parent class.
Common functionality needs to be designed in the parent class.
Parent classes are usually more specific than child classes.
Question 2.2. (TCO 4) There are two classes: class GeometricObject and class Cylinder. Which one is the base class and which one is the derived class? (Points : 5)
class GeometricObject is the derived class from Cylinder.
They have nothing in common and therefore have no relationships.
class Cylinder is the base class.
class Cylinder is derived from GeometricObject.
Question 3.3. (TCO3) Which of the following is true about identifying a class based on a set of requirements? (Points : 5)
After the requirements are documented, the process of identifying classes can begin
One way to identify classes is to identify nouns in the problem analysis
Responsibilities of each class need to be identified after classes are identified
All of the above
Question 4.4. (TCO3) What does SOW stand for in the object-oriented design process? (Points : 5)
Sequence of work
Structure of work
Statement of work
None of the above
Question 5.5. (TCO 4) What are the benefits of creating another derived class instead of adding new functionality to the existing class? (Points : 5)
Saves time on debugging the program
Simplifies testing
No need to re-test the previously written class
All of the above
None of the above
Question 6.6. (TCO 6) What is polymorphism? (Points : 5)
An advanced form of inheritance
A single usefulness for program specificity
One interface, many implementations
Data hiding
Question 7.7. (TCO 2) Which of the following is a proper implementation for a getter? (Points : 5)
int getDayOfBirth() { return day;}
void getDayOfBirth() {return day;}
int getDayOfBirth (int day) {this-day = day;}
void getDayOfBirth () {return day;}
Question 8.8. (TCO 4) Consider the following class definitions.
class bClass
{
public:
void setX(int a);
//Postcondition: x = a;
void print() const;
private:
int x;
};
class dClass: public bClass
{
public:
void setXY(int a, int b);
//Postcondition: x = a; y = b;
void print() const;
private:
int y;
};
Which of the following correctly sets the values of x and y? (Points : 5)
void dClass::setXY(int a, int b)
{
bClass::setX(a);
y = b;
}
void dClass::setXY(int a, int b)
{
x = a;
y = b;
}
void dClass::setXY(int a, int b)
{
x = bClass::setX(a);
y = bClass::setY(b);
}
void dClass::setXY(int a, int b)
{
x = bClass.setX(a);
b = y;
}
Question 9.9. (TCO 1) Examine the class definition. How many members does it contain?
class Date
{
public:
void setDate(int, int, int);
void printDate() const;
int getDay(); int getDay(); int getDay();
private:
int day;
int month;
int year;
};
(Points : 5)
8
3
6
None of the above
Question 10.10. (TCO 8) Data/information hiding and encapsulation improves construction and maintenance because: (Points : 5)
Adding additional details is isolated to a single class
Program bugs are isolated to a single class
Programming to an interface makes the code more logical
All of the above
None of the above
Question 11.11. (TCO 8) What are some of the characteristics of “self-documenting” code? (Points : 5)
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 12.12. (TCO 9) The purpose of a namespace is to: (Points : 5)
organize your code.
give you a way to create global types.
provide a container for logically related items.
All of the above
None of the above
Page 3
Question 1.1. (TCO 8) Please briefly describe best practices as it relates to method names. (Points : 18)
Question 2.2. (TCO 2) Sometimes the terms Encapsulation and Data/Information Hiding in object-oriented programming are used interchangeably. Is it correct to use the terms interchangeably? Why or why not?(Points : 18)
Question 3.3. (TCO 2) Given the following list of classes, attributes and methods,
· identify which items are classes, which items are attributes and which items are methods;
· identify which class each attribute and method belongs to; and
· suggest a class hierarchy given your list of classes.
*Note – no particular capitalization scheme is used in the list below to differentiate between classes, methods, and attributes.
LandOnStatue, NumberOfLegs, Height, ShoeSize, Eat, Animal, Speak, WingSpan, Age, Peck, Sleep, Horse, LengthOfMane, Move, BeakLength, LengthOfTail, Bird, SaddleUp (Points : 18)
Question 4.4. (TCO 7) How are pure virtual functions created? When a class contains one pure virtual function, what will happen? Can we still treat the class like a normal class? (Points : 18)
Question 5.5. (TCO 4) What are a bass class and a derived class? How do you distinguish between a base class and its derived classes? What programming technique shall you follow when the implementation of a base class method does not appropriately describe the behavior of a derived class object? (Points : 18)
Question 6.6. (TCO 6) How does polymorphism promote extensibility? How does polymorphism enables you to program “in the general” rather than “in the specific.” Explain the key advantages of programming “in the general.” (Points : 18)
Question 7.7. (TCO 2) Define and implement the overloaded constructors that support the following test function for a Triangle class. The data members for the Triangle class are:
• triangleBase– integer number
• height– integer number
int main()
{ Triangle t1(); //t1 will take all default value
Triangle t2(3, 10); //t2 will take all supplied value
Triangle t3(5); //t3 will take supplied triangleBase, height will take default value
Triangle t4 = t2; //t4 will take the same value of t2
//the rest of the code
}
(Points : 22)