OOP C++
48 questions
Essay Questions
Question 1.1. (TCO 1) Given the following array declaration and program statement, describe–in detail–the condition and what potential problems could occur if a program containing both was compiled and executed. Question 2.2. (TCO 2) Explain the basic C++ syntax for creating a class. Include an explanation of the private and public section of a class and the class members. Include a code segment to illustrate your answer. (Points : 10) Question 3.3. (TCO 3) Write and explain the definition of what composition is and how it is useful in writing an object-oriented program. Also, explain how it is different from inheritance and how both inheritance and composition are useful in developing object-oriented programs. (Points : 10) Question 4.4. (TCO 4) If a class is derived protected from a base class, explain how this affects the inheritance of all the public, protected, and private members of the base class by the derived class. (Points : 10) Question 5.5. (TCO 5) When dynamically allocating memory for a specific data type, explain why a pointer variable of the same data type must be used. Describe what happens if the memory allocation is successful and what happens if it is unsuccessful. (Points : 10) Question 6.6. (TCO 6) List and describe three restrictions regarding operator overloading. (Points : 10) Question 7.7. (TCO 7) Define what is meant by the term run-time binding, and list two other terms that are also used to describe it. (Points : 10) Question 8.8. (TCO 8) Describe and define what the preprocessor statement is, how it is used, what part of the development environment it interacts with, and provide a syntactically correct example that describes what it does. (Points : 10) |
Page 1
Multiple Choice Questions
Question 1.1. (TCO 1) What is the value of alpha[3] after the following code executes? 5 Question 2.2. (TCO 1) After the following statements execute, what are the contents of the matrix? |
Page 2
Multiple Choice
Question 1.1. (TCO 2) Suppose you have the following UML class diagram of a class. incrementHours Question 2.2. (TCO 2) Suppose you have the following UML class diagram of a class. incrementHours Question 3.3. (TCO 2) Consider the following declaration. myObject.print = 10; Question 4.4. (TCO 3) Composition is a stronger form of _____. (Points : 4) inheritance Question 5.5. (TCO 3) Composition and inheritance are two fundamental ways of relating _____. (Points : 4) classes Question 6.6. (TCO 3) Aggregation is also sometimes called _____. (Points : 4) inheritance Question 7.7. (TCO 3) Which of the following statements is an accurate example of composition? (Points : 4) A car has an engine. Question 8.8. (TCO 4) If the derived class does not override a public member function of the base class, you may specify a call to that public member function that has parameters by _____. (Points : 4) using the name of the function and no parameter list Question 9.9. (TCO 4) Which of the following is a valid definition of the derived class bClass? (Points : 4) class aClass: public bClass{ //…}; Question 10.10. (TCO 4) Which of the following statements correctly describes an example of multiple inheritance? (Points : 4) Mother and Father to Children |
Page 3
Multiple Choice
Question 1.1. (TCO 4) Which of the following relationships is not a correct example of inheritance? (Points : 4) Parent to Children Question 2.2. (TCO 4) To overload a member function of the base class, _____. (Points : 4) the name of the function and the formal parameter list of the corresponding function in the derived class must be same Question 3.3. (TCO 4) Which of the following is not true about public inheritance? (Points : 4) All the public member functions of the base class become the public member functions of the derived class. Question 4.4. (TCO 5) What is the data type of pDist? Distance Question 5.5. (TCO 5) Given the definition of a class called Employee and given an Employee pointer variable called myData, which is pointing to an array of 20 Employee objects, which of the following statements correctly accesses the getSalary method of the last employee that takes no parameters and returns a double value? (Points : 4) cout << *(myData + 20).getSalary( );
cout << myData[20].getSalary( );
cout << myData->getSalary[19]; Question 20.20. (TCO 8) In a multifile, object-oriented, C++ project, which is the correct statement for the constructor implementation, given that the constructor is correctly defined in the class definition file? (Points : 4) Classname:Classname{ } |