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

Page 2 1. (TCO 4) Which of the following design rules apply to inheritance? (Poi

ID: 3538301 • Letter: P

Question

Page 2

1. (TCO 4) Which of the following design rules apply to inheritance? (Points : 5)       Common functionality needs to be pushed to the parent class.
      Inheritance demonstrates the generalization/specialization relationship
      A child class can itself be a parent class
      All of the above

2. (TCO 4) A Lamp class, LightBulb and OilLamp class have what type of relationships? (Points : 5)       The Light uses a LightBulb, and the Light is an OilLamp.
      The LightBulb has an OilLamp, and the OilLamp is a Light.
      The Light has a LightBulb, and the OilLamp is a Light
      The LightBulb has an OilLamp, and the Light is an OilLamp.

3. (TCO3) Which of the following might be potential class(es) in an application? (Points : 5)       shape
      colorShape
      drawShape
      All of the above
      None of the above

4. (TCO3) What happens right after we gather requirements in the object-oriented design process? (Points : 5)       Developing SOW
      Identify classes
      Creating UML diagram
      Develop prototype

5. (TCO 4) In object-oriented programming, inheritance is transitive; that means a child class _____. (Points : 5)       inherits only from its parent class
      inherits only selected methods and fields
      inherits all the methods and fields of all its ancestors
      does not inherit any methods or fields

6. (TCO 6) Which of the following are benefits of using inheritance? (Points : 5)       Smaller chance of errors
      Code is more manageable
      Prevents the need to duplicate code, and therefore creates efficiency in the programming process.
      All of the above
      None of the above

7. (TCO 2) Which of the following is a proper implementation for a setter? (Points : 5)       int setNumberOfLegs() { return legs;}
      void setNumberOfLegs (int legs) {this->legs = legs;}
      void setNumberOfLegs (int legs) {return legs;}
      void setNumberOfLegs () {return legs;}

8. (TCO 4) Assuming the following is a constructor for class Circle

Circle::Circle( double r, int a, int b )
: Point( a, b )

What does the second line do?
(Points : 5)       Invokes the Point constructor with values a and b
      Causes a compiler error
      It is unnecessary because the Point constructor is called automatically
      Indicates inheritance

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

class Date
{
public:
void setDate(int, int, int);
void printDate() const;
void setDay(int);
void setMonth(int);
void setYear(int);
int getDay(); int getDay(); int getDay();
private:
int day;
int month;
int year;
};
(Points : 5)       6
      3
      9
      11
      None of the above

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

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) 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

Explanation / Answer

1.D

2.A

3.D

4.B

5.A

6.D

7.B

8.C

9.D

10.D

11.D

12.D