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

#include <iostream> using namespace std; int main () { int foo; int *foo2; foo2

ID: 3541149 • Letter: #

Question

#include <iostream>
    using namespace std;
    int main ()
    {
         int foo;
         int *foo2;
         foo2 = &foo;
         foo = 1234;
         cout << *foo2 << end1;
         return 0;
    }
    
    

                     2. (TCO 2) A ____ sign in front of a member name on the UML diagram indicates that this member is a public member. (Points : 4)                                           +
                                        -
                                        #
                                        $
                          Suppose that you have the following UML class diagram of a class. Which of the following is the name of the class? sign in front of a member name on the UML diagram indicates that this member is a public member. Consider the following class definition: Composition is a stronger form of Composition is when one or more members of a class are Aggregation is also sometimes called Consider the following class definition: Consider the following class definitions: Which of the following statements correctly describes an example of multiple inheritance? For the code fragment below, if the address of foo is bff00fa10 hex and the address of foo2 is bff00a14 hex, what is the output? For the statement int *p, how many bytes of storage are allocated on a Pentium class system using 32-bit addressing? Which of the following statements correctly allocates space to store 15 real numbers? When a class uses dynamic memory allocation, the destructor of the class must:

Explanation / Answer

1. (TCO 2) Suppose that you have the following UML class diagram of a class.
F:comp220Untitled-1_clip_image002.gif
Which of the following is the name of the class? (Points : 4)

clock
clockType
Type
ClockType

UML DIAGRAM IS MISSING

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

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

class circleType
{
public:
void set(double r);
//Postcondition: radius = r;
void print();
//Output radius, area, and circumference.
double area();
//Postcondition: Calculate and return area.
double circumference();
//Postcondition: Calculate and return circumference.
circleType();
//Postcondition: radius = 0;
circleType(double r);
//Postcondition: radius = r;
private:
double radius;
};

Which of the following statements are valid in C++?

(i)
cin >> r;
myCircle.area = 3.14 * r * r;
cout

(ii)
cin >> r;
myCircle.set(r);
cout

(Points : 4)
Only (i)

4. (TCO 3) Composition is a stronger form of ______. (Points : 4)

aggregation

5. (TCO 3) Composition is when one or more members of a class are (Points : 4)

objects of another class type.

6. (TCO 3) Aggregation is also sometimes called ______. (Points : 4)

composition

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)

private


8. (TCO 4) Consider the following class definitions:

class bClass
{
public:
void setX(int);
void print() const;
private:
int x;
};

class dClass: public bClass
{
public:
void setXY(int, int);
void print() const;
private:
int y;
};

Which of the following statements correctly redefines the member function print of bClass?

(Points : 4)
void dClass::print() const { bClass::print(); cout }

9. (TCO 4) Which of the following statements correctly describes an example of multiple inheritance? (Points : 4)
Mother and Father to Children

10. (TCO 5) For the code fragment below, if the address of foo is bff00fa10 hex and the address of foo2 is bff00a14 hex, what is the output?

#include <iostream>
using namespace std;
int main ()
{
int foo;
int *foo2;
foo2 = &foo;
foo = 1234;
cout << *foo2 << end1;
return 0;
}

(Points : 4)
1234

11. (TCO 5) For the statement int *p, how many bytes of storage are allocated on a Pentium class system using 32-bit addressing? (Points : 4)

Four

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

13. (TCO 5) When a class uses dynamic memory allocation, the destructor of the class must: (Points : 4)
set all dynamically allocated data to zero.
return any dynamically allocated memory to the system.
explicitly destroy all objects of the class.

All of the above