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

1. (TCO 2) Given the declaration: class myClass { public: void print(); int y; p

ID: 3657445 • Letter: 1

Question

1.(TCO 2) Given the declaration:

class myClass {
public:
void print();
int y;
private:
int x;
};
myClass myObject;

which statement is legal?(Points : 4) myObject.x = 10;
myClass.x = 10;
myObject.y = 10;
myClass.y = 10;

2.(TCO 2) The components of a class are called the _____ of the class.(Points : 4) elements
members
objects
properties

3.(TCO 2) Suppose that you have the following UML class diagram of a class.

Which of the following is an accessor?(Points : 4) incrementHours
equalTime
getTime
printTime

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

5.(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 class variable declarations is correct?(Points : 4) rectangle rectangleType;
class rectangleType rectangle;
rectangleType rectangle;
rectangle rectangleType.area;

6.(TCO 3) Composition is when one or more members of a class are(Points : 4) accessed by member functions of the same class.
objects of another class type.
defined in a separate file.
created in a class tester program.

7.(TCO 8) If a Class A has an object of Class B as a data member, what type of function must be used for an object of Class A to obtain a copy of a private data member of Class B?(Points : 4) Class B copy constructor
Class B accessor function
Class A accessor function
It is not possible for an object of Class A to do this action.

8.(TCO 8) What is a preprocessor directive?(Points : 4) An instruction to the preprocessor
An instruction to the linker
An instruction to the debugger
An instruction to the compiler

9.(TCO 8) What is the namespace commonly used with <iostream>?(Points : 4) std
standard
.h
cin and cout

10.(TCO 8) Which preprocessor directive is not used for conditional compilation?(Points : 4) define
ifndef
ifdef
endif

Explanation / Answer

The right is :

myClass.x = 10;

plz rate