Test1Key
Home ] Up ]

 

CSIS 250 Fall 2000 T1

Your Name

 

Your Secret Name

 

 

Assume the following definitions for the questions that follow.

int const MAX_VALUE  = 10;

int const TEST_COUNT = 20;

 

class CMoney

  {

  private:

    int dollars;

    int cents;

  public:

    CMoney(int dollars=0, int cents=0);

    CMoney(char ch);

    ~CMoney(void);

    void display(void) const;

    CMoney operator -();

    bool operator ==(CMoney amount);

    bool equal    (CMoney amount);

    bool operator !=(CMoney amount);

    CMoney operator + (CMoney amount) const;

    CMoney add      (CMoney amount) const;

  };

 

1.  Identify the purpose of the following statement.

   CMoney *m1, *m2;

 

a)            Create one pointer variable and one object variable

b)            Create two pointer variables

c)            Create two object variables

d)            Create one pointer variable

e)            None of the above

2.  Identify the purpose of the word “this”  in the following statement.

   this->dollars = dollars;

 

a)                 Points to the object amount

b)                 Points to the object in operation

c)                 Points to a global object amount

d)                 Points to the object amount1

e)                 None of the above

3.  Identify the purpose of the following statement.

   cents = rand()%100;

 

a)          Assigns a random value from 0 to 100

b)          Assigns a random value from 1 to 100

c)          Assigns a random value from 1 to 99

d)          Assigns a random even value from 2 to 100

e)          None of the above

4.  Identify the missing statement in the following function.

   void swap (int &x, int &y)

    {

    int temp;

    temp = x;

    x = y;

    ...

    }

 

a)          y = x;

b)          temp = y;

c)          x = temp;

d)          temp = x;

e)          None of the above

5.  Identify the missing statement in the following operator definition assuming that the operator == is already defined.

bool CMoney::operator !=(CMoney amount)

  {

  ...

  }

 

a)          return !(this == amount);

b)          return (*this != amount);

c)          return (this != *amount);

d)          return (*this == amount);

e)          none of the above

 

Assume the following definitions for the questions that follow.

int TEST_COUNT = 5;

 

class CPoint

  {

  private:

    int x;

    int y;

  public:

    CPoint (int a=0, int b=0);

    CPoint (char ch);

    void display(void) const;

    void setX (int a);

    void setY (int b);

    void setXY (int a, int b);

    int getX(void) const;

    int getY(void) const;

    void getXY (int &a, int &b) const;

    void copyTo (CPoint &p) const;

    void copyFrom (const CPoint &p);

    bool isEqualTo (const CPoint &p) const;

  };

 

6.  Identify the missing statement in the following function.

bool CPoint::isEqualTo (const CPoint &p) const

  {

  ...

  }

 

a)          return ((x = p.x) || (y = p.y));

b)          return ((x = p.x) && (y = p.y));

c)          return (x = p.x) & (y = p.y);

d)          return ((x = p.x) & (y = p.y));

e)          none of the above

7.  Identify the missing statement in the following function.

CPoint::CPoint(int a, int b)

  {

  ...

  x=a;

  y=b;

  }

 

a)          b=y;

b)          int x, y;

c)          int a, b;

d)          int t;

e)          none of the above

8.  Identify the missing statement in the following function.

void CPoint::setX(int a)

  {

  ...

  }

 

a)          int x;

b)          int a;

c)          x=a;

d)          a=x;

e)          none of the above

9.  Identify the statement to set the x coordinate of a point p to 5.

a)          setX.p(5);

b)          p->setX(5);

c)          (*p).setX(5);

d)          p.setX(5);

e)          none of the above

10.  Identify the missing statement in the following function definition.

void CPoint::setXY(int a, int b)

  {

  x=a;

  ...

  }

 

a)          b=y;

b)          int b;

c)          int x;

d)          y=b;

e)          none of the above

11.  Identify the missing statement in the following function definition.

int CPoint::getX(void) const

  {

  ...

  }

 

a)          return this;

b)          return *this;

c)          return this.x;

d)          return this->x;

e)          none of the above

12.  Identify the missing statement in the following function.

void CPoint::getXY(int &a, int &b) const

  {

  a=x;

  ...

  }

 

a)          b=*y;

b)          b=y;

c)          b=this;

d)          y=b;

e)          none of the above

13.  Identify the missing statement in the following function.

void CPoint::copyTo(CPoint &p) const

  {           

  ...

  p.y = (*this).y;

  }

 

a)          p.x = this.x;

b)          p.x = p.x;

c)          p.x = x.y;

d)          p.x = this->x;

e)          none of the above

14.  Identify the missing statement in the following function.

void CPoint::copyFrom (const CPoint &p)          

  {

  x=p.x;

  ...

  }

a)          y=p->y;

b)          y=(*p).y;

c)          y=p.y;

d)          y=*p;

e)          none of the above

Assume the following definitions for the questions that follow.

const int MIN_DIM   = 1;

const int MAX_DIM   = 19;

const int TEST_COUNT = 5;

 

class CRectangle

  {

  private:

   int length;

   int width;

  public:

   CRectangle(int len=1, int wid=1);

   int perimeter(void) const;

   int area(void) const;

   void setDimension(int len, int wid);

   void setLength(int len);

   void setWidth(int wid);

   int getLength(void) const;

   int getWidth(void) const;

   void getDimension(int &len, int &wid) const;

   void display(void) const;

   int & badSet(void);

   CRectangle(char ch);

   ~CRectangle(void);

   friend bool isSquare(const CRectangle &rect);

  };

15.  Identify the missing statement in the following function.

bool isSquare(const CRectangle &rect)

  {

  ...

  }

 

a)          return (length == width);

b)          return (length = width);

c)          return (rect.length == rect.width);

d)          return (rect->length == rect->width);

e)          none of the above

16.  Identify the missing statement in the following function.

int CRectangle::getLength(void) const

  {

  ...

  }

 

a)          return length;

b)          return this.length;

c)          return (*this)->length;

d)          return width;

e)          none of the above

17.  Identify the missing statement in the following function.

int CRectangle::perimeter(void) const

  {

  ...

  }

 

a)          return (length+width);

b)          return length+width;

c)          return 2*length+width;

d)          return (2+(length+width));

e)          none of the above


CSIS 250 Fall 2000 T1

Your Name

 

Your Secrete Name

 

 

1.

a

b

c

d

e

2.

a

b

c

d

e

3.

a

b

c

d

e

4.

a

b

c

d

e

5.

a

b

c

d

e

6.

a

b

c

d

e

7.

a

b

c

d

e

8.

a

b

c

d

e

9.

a

b

c

d

e

10.

a

b

c

d

e

11.

a

b

c

d

e

12.

a

b

c

d

e

13.

a

b

c

d

e

14.

a

b

c

d

e

15.

a

b

c

d

e

16.

a

b

c

d

e

17.

a

b

c

d

e