1. (TCO 1) Which of the following would be a more appropriate choice for a method in a PhoneCharger class? (Points : 5)Voltage()Manufacturer()Current()Charge()Question 2. 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 aboveNone of the aboveOnly A, B, and DQuestion 3. 3. (TCO 2) Which of the following components of a class definition do not have an access modifier? (Points : 5)State variablesData membersMember methodsDestructorNone of the aboveQuestion 4. 4. (TCO 2) Which of the following statements is/are true? (Points : 5)A. In general, reusable classes tend to have interfaces that are more abstract than concrete.B. The compiler generated default constructor does the exact same job as any user defined default constructorC. A private (helper) method is part of a classs interfaceNone of the aboveOnly A and BQuestion 5. 5. (TCO 5) Which of the following method pairs are not examples of method overloading? (Points : 5)public void Bake() ; public int Bake()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)None of the aboveOnly A and BQuestion 6. 6. (TCO 1) Which of the following statements is/are false? (Points : 5)Abstraction is the process of ignoring the high level information about a category entity or activity, while concentrating on the unimportant details.The object-oriented paradigm permits the modeling of a software system in a more natural way compared to the procedural paradigm.In object-oriented programming, we design the program as a set of cooperating objects.None of the aboveQuestion 7. 7. (TCO 2) You have been tasked to create an Automobile 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 as many class attributes public as you can, creating accessor/mutators for each one.Package attributes and behaviors specific to an Automobile together.Make sure to include a specific implementation for a drive method that all subclasses can inherit.Declare the class as private.All of the aboveQuestion 8. 8. (TCO 2) A black box is a term used to describe a system that can be understood solely based on its inputs, a description of its _____ and the resulting outputs. (Points : 5)processinginherited processesattributesaccessorsQuestion 9. 9. (TCO 2) A class is designed with two public attributes: attributeOne and attributeTwo. attributeOne is an integer data type while attributeTwo is a string data type. Which pseudocode representation(s) of setters would be appropriate for this class? (Points : 5)int setAttributeOne(int newAttributeOne){return attributeOne}void setAttributeOne(int newAttributeOne){attributeOne = newAttributeOne}string setAttributeTwo (int newAttributeTwo){attributeTwo = newAttributeTwo}void setAttributeTwo (){attributeTwo = }Both A and CNone of the aboveQuestion 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 aboveQuestion 11. 11. (TCO 7) A(n) _____ cannot be instantiated and therefore is used only to form related derived classes. (Points : 5)methodabstract methodclassabstract classQuestion 12. 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)contractinheritance hierarchyhas-a relationshipobject constructed with a multi-arg constructorAll of the above13. (TCO 4) If you have a complete, working Box class that has been thoroughly tested, and you wish to add an overloaded displayVolume() method that can display the location and volume of a GraphicBox, how should this be accomplished? (Points : 5)Derive a new GraphicBox class from the first Box class.Add the method to your existing Box class.Make a brand new class.Add the method in the same class as the main.Question 14. (TCO 3) An Order class and RushOrder class have what type of relationships? (Points : 5)The Order has-a RushOrder.The Order is-a RushOrder.The RushOrder has-an Order.The RushOrder is-an Order.Question 15. (TCO 4) Why might it be better to create a derived class instead of adding a few lines of code to an existing Class? (Points : 5)Simplifies testingNo need to re-test the previously written classSaves time on debugging the programAll of the aboveNone of the aboveQuestion 16. (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? (Points : 5)Child, Parent, GrandParentParent, GrandParent, ChildGrandParent, Child, ParentGrandParent, Parent, ChildQuestion 17. (TCO 6) The ability to reuse objects already defined, perhaps for a different purpose, with modification appropriate to the new purpose, is referred to as _____. (Points : 5)information hiding.inheritance.redefinition.overloadingQuestion 18. (TCO 4) Which of the following is not a good example of a hierarchy that could be modeled with inheritance? (Points : 5)AirplanesGeometric shapesAnimalsPrime numbersQuestion 19. (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;}; (Points : 5)73An average of 5 because (7 + 3) / 2 = 510Question 20. (TCO 7) Which of the following declares a pure virtual function in an abstract C++ class? (Points : 5)public void cookIngredients() {}public void cookIngredients()public void cookIngredients()=0;public cookIngredients();Question 21. (TCO 4) Suppose that bClass is a class. Which of the following statements correctly derives the class dClass from bClass? (Points : 5)class dClass:: public bClass{//classMembersList};class dClass: private bClass{//classMembersList};class dClass:: protected bClass{//classMembersList};class bClass: public dClass{//classMembersList};Question 22. (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 aboveNone of the aboveQuestion 23. (TCO 8) What are some of the characteristics of a good comment? (Points : 5)Summary comments that distill the logic of an algorithmComments are well-written and clearComments showing the intent of the codeAll of the aboveNone of the aboveQuestion 24. (TCO 9) The purpose of a namespace is to: (Points : 5)organize your code.gives you a way to create global types.provide a container for logically related items.All of the aboveNone of the above
ESSAY QUESTIONS
- (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)
Question 2. 2. (TCO 2) Provide an example that shows how we can have Encapsulation without Data/Information Hiding in object-oriented programming. (Points : 18)
Question 3. 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 persons house. The program must keep track of all items owned by the houses 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)
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) Consider the class Bicycle. Given your knowledge of some common components of bicycles
show a class hierarchy in which the class Bicycle inherits from other classes, which, in turn, can also be inherited from yet other classes; discuss inheritance from class Bicycle for other closely related derived classes; and discuss the common components of class Bicycle. (Points : 18)
Question 6. 6. (TCO 3) How does the has-a relationship relate to composition? Give an example of such a relationship. (Points : 18)
Question 7. 7. (TCO 2) Define and implement the overloaded constructors that support the following test function for a StudentEmployee class. The data members for the StudentEmployee class are:
age integer number name String DSI String salary floating point number
int main(){ //s1 will take all default valueStudentEmployee s1();//s2 will take all supplied valuesStudentEmployee s2 (50, Jackie Chan, D87654321, 10000000.99);//s3 will take supplied age value, name, DSI and salary will take default valuesStudentEmployee s3 (25);//s4 will take supplied age and name value, DSI and salary will take default valuesStudentEmployee s4 (35, Jenny);//s5 will take supplied age, name and DSI value, salary will take default valueStudentEmployee s5 (45, Jack, D11223344);//s6 will take supplied age, name and salary value, DSI will take default valueStudentEmployee s6 (60, James Bond, 65000.0);//s7 will take the same value of s2StudentEmployee s7=s2;
//the rest of the code}(Points : 22)
Reviews
There are no reviews yet.