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

QUESTION 3 Consider the UML class diagram shown in the accompanying figure. Whic

ID: 3857952 • Letter: Q

Question

QUESTION 3

Consider the UML class diagram shown in the accompanying figure. Which of the following is the name of the class?

clock

clockType

Type

+clockType

1 points   

QUESTION 4

class secretType
{
public:
  static int count;
  static int z;

  secretType();
  secretType(int a);
  void print();
  static void incrementY();

private:
  int x;
  static int y;
};

secretType::secretType()
{
  x = 1;
}

secretType::secretType(int a)
{
  x = a;
}

void secretType::print()
{
  cout << "x = " << x << ", y = " << y
       << "z = " << z
       << ", count = " << count << endl;
}

static void secretType::incrementY()
{
  y++;
}

Consider the accompanying class and member functions definitions. How many constructors are present in the class definition?

none

one

two

three

1 points   

QUESTION 5

A class object can be ____. That is, it is created each time the control reaches its declaration, and destroyed when the control exits the surrounding block.

static

local

public

automatic

1 points   

QUESTION 6

Which of the following class definitions is correct in C++?

class studentType
{
public:
  void setData(string, double, int);
private:
  string name;
};

class studentType
{
public void setData(string, double, int);
private string name;

};

studentType class
{
public: void setData(string, double, int);
private: string name;

};

class studentType
{
public:
  void setData(string, double, int);
  void print() const;
private:
  string name;
  double gpa;

}

1 points   

QUESTION 7

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;
};

Consider the accompanying class definition, and the object declaration:

rectangleType bigRect(14,10);

Which of the following statements is correct?

bigRect.length = 2.0;

bigRect.setLengthWidth();

bigRect.length = bigRect.width;

bigRect.setLengthWidth(3.0, 2.0);

1 points   

QUESTION 8

How many destructors can a class have?

no explicit destructors

one

two

any number

1 points   

QUESTION 9

A class object can be ____. That is, it can be created once, when the control reaches its declaration, and destroyed when the program terminates.

static

local

automatic

public

1 points   

QUESTION 10

Consider the UML class diagram shown in the accompanying figure. According to the UML class diagram, how many private members are in the class?

none

zero

two

three

clockType -hr: int
-min: int
-sec: int +setTime(int, int, int): void
+getTime(int&, int&, int&) const: void
+printTime() const: void
+incrementSeconds(): int
+incrementMinutes(): int
+incrementHours(): int
+equalTime(const clockType&) const: bool

Explanation / Answer

3. b) clockType

4. c) two -- one default and one parametrized.

5. d) automatic

6. a)

class studentType
{
public:
  void setData(string, double, int);
private:
  string name;
};

7. d) bigRect.setLengthWidth(3.0, 2.0);

8. b) one - class can have multiple constructor, but only one destructor

9. a) static

10. d) three - private members are those who have - sign in front

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote