# COMP220 Week 8 – Study Material for Finals – 15 MCQs, 8 Essay Questions – Guaranteed 100% score

Quiz Price = \$20
[orb_cyber_store id=”315″]
Problem Statement
Page 2

Multiple Choice Questions
1. (TCO 2) Which of the following class definitions is correct in C++?

(i)
class student
{
public:
void student();
void student(string s, double g, int i);
void set(string s, double g, int i);
void print();
private:
string name;
double gpa;
int id;
};
(ii)
class student
{
public:
student();
student(string s, double g, int i);
void set(string s, double g, int i);
void print();
private:
string name;
double gpa;
int id;
};

(Points : 4)
Only (i)
Only (ii)
Both (i) and (ii)
None of these

2. (TCO 2) A ____ sign in front of a member name on the UML diagram indicates that this member is a protected member. (Points : 4)
+

#
\$

3. (TCO 2) Consider the following class definition.

class rectangleType
{
public:
void setLengthWidth(double x, double y);
//Postcondition: length = x; width = y;
void print() const;
//Output length and width;
double area();
//Calculate and return the area of the rectangle;
double perimeter();
//Calculate and return the parameter;
rectangleType();
//Postcondition: length = 0; width = 0;
rectangleType(double x, double y);
//Postcondition: length = x; width = y;
private:
double length;
double width;
};

Which of the following statements is correct?

(Points : 4)
rectangleType.print();
rectangleType::print();
bigRect.print();
bigRect::print();

4. (TCO 3) A(n) _____ relationship represents composition. (Points : 4)
“has a”
“is a”
“part of”
logical

5. (TCO 3) Which of the following statements is an accurate example of composition? (Points : 4)
A car has an engine.
A car is an automobile.
A car is an object.
A car has a class.

6. (TCO 3) Which is the correct UML connector to designate inheritance? (Points : 4)

7. (TCO 4) Consider the following class definition:

class dClass: bClass
{
//class members list
};

The class dClass is derived from the class bClass using the ____ type of inheritance.

(Points : 4)
public
private
protected
static

8. (TCO 4) If class AClass is derived from class BClass, which one of the following statements correctly states the constructor call sequence when an object of class AClass is instantiated? (Points : 4)
BClass constructor first, AClass constructor second
AClass constructor first, BClass constructor second
BClass constructor only, the AClass constructor is not called if AClass derived private from BClass
AClass constructor only, the BClass constructor is not called if BClass derived private from AClass

9. (TCO 4) Which of the following base class members is never inherited by a derived class, regardless of access attributes? (Points : 4)
Mutator
Data
Accessor
Destructor

10. (TCO 5) If p is a pointer, which statement uses the pointer, then increments it? (Points : 4)
*++p
*p++
*p–
*–p

11. (TCO 5) What is the data type of pDist?

Distance * pDist; (Points : 4)
Distance
Const pointer to Distance
Pointer to Distance
Pointer to MAX

12. (TCO 5) Which of the following statements correctly allocates space to store 15 real numbers? (Points : 4)
double *dptr = new double;
double dptr = new double;
double *dptr = new double;
real *iptr = new real;

13. (TCO 5) What will be the output of the following code snippet?

int *list = new int;
int *ptr;
for(i = 0; i < 5; i++) list[i] = i+1; ptr = list; delete [] list; cout << *ptr; (Points : 4) 1 address of list address of ptr error - ptr references memory which no longer belongs to the program 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. 2. (TCO 2) Compare and contrast constructors and destructors. Provide an example class that includes both a constructor and a destructor function. (Points : 10) 3. (TCO 3) Assume that a definition of class Automobile has two composite objects called myEngine of class Engine and myTransmission of class Transmission. If an object of Automobile is instantiated and then goes out of scope, list the sequence in which all the constructors and destructors are called. Also, provide an explanation of how they are called in this sequence. (Points : 10) 4. (TCO 4) Explain how access privileges affect members of the derived class and the objects created from them. 5. (TCO 5) Describe what a memory leak is and why it could cause problems. 6. (TCO 6) Assume that three objects of the class Inductor have been instantiated: L1, L2, and L3. Write the overloaded operator prototypes that would be required to perform the following operation. You are only required to write the prototypes, not the implementation code. 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) 8. (TCO 8) For a multifile project that contains just one class, list and describe each of the files that would be required to implement and test the functions of the class. (Points : 10)

Relevant Material
Instructions
* Please click on “Buy Now” button to complete the purchase.Please note that the payment is done through PayPal.
* If you have any issues with the payment method, please let us know at [email protected] and that can be discussed and considered.
* Your paypal has to be pre-loaded in order to complete the purchase or otherwise please discuss it with us at [email protected].