CSC102 Ch 10 Quiz

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

A class and its members can be described graphically using a notation known as the ____ notation.

UML

What does ADT stand for?

abstract data type

T/F? In C++, class is a reserved word and it defines only a data type.

True

How many destructors can a class have?

one

A destructor has the character ____, followed by the name of the class.

~

A ____ sign in front of a member name on a UML diagram indicates that this member is a protected member.

#

A ____ sign in front of a member name on a UML diagram indicates that this member is a public member.

+

In C++, the ____ is called the member access operator.

.

In C++, the scope resolution operator is ____.

::

Which of the following is true about classes and structs? a. An assignment operator is allowed on class variables, but not on struct variables. b.By default, all members of a struct are public and all members of a class are private. c.A struct variable is passed by value only, and a class variable is passed by reference only. d. You cannot use the member access specifier private in a struct.

By default, all members of a struct are public and all members of a class are private.

T/F? As parameters to a function, class objects can be passed by reference only.

False

T/F? Given the declaration class myClass { public: void print(); //Output the value of x; MyClass(); private: int x; }; myClass myObject; The following statement is legal. myObject.x = 10;

False

T/F? If an object is created in a user program, then the object can access both the public and private members of the class.

False

T/F? If the heading of a member function of a class ends with the word const, then the function member cannot modify the private member variables, but it can modify the public member variables.

False

T/F? The public members of a class must be declared before the private members.

False

T/F? You can use arithmetic operators to perform arithmetic operations on class objects.

False

T/F? A class is an example of a structured data type.

True

T/F? If an object is declared in the definition of a member function of the class, then the object can access both the public and private members of the class.

True

T/F? In C++ terminology, a class object is the same as a class instance.

True

A member function of a class that only accesses the value(s) of the data member(s) is called a(n) ____ function.

accessor

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.

automatic

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 declaration: rectangleType bigRect; Which of the following statements is correct? a. rectangleType.print(); b. rectangleType::print(); c. bigRect.print(); d. bigRect::print();

bigRect.print();

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? a. bigRect.setLengthWidth(3.0, 2.0); b. bigRect.setLengthWidth(); c. bigRect.length = 2.0; d. bigRect.length = bigRect.width;

bigRect.setLengthWidth(3.0, 2.0);

Which of the following class definitions is correct in C++? a. studentType class { public: void setData(string, double, int); private: string name; }; b. class studentType { public: void setData(string, double, int); void print() const; private: string name; double gpa; } c. class studentType { public void setData(string, double, int); private string name; }; d. class studentType { public: void setData(string, double, int); private: string name; };

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

A program or software that uses and manipulates the objects of a class is called a(n) ____________________ of that class.

client

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 Consider the UML class diagram shown in the accompanying figure. Which of the following is the name of the class?

clockType

In C++, you can pass a variable by reference and still prevent the function from changing its value by using the keyword ____ in the formal parameter declaration.

const

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 The word ____ at the end of several the member functions in the accompanying figure class clockType specifies that these functions cannot modify the member variables of a clockType object.

const

To guarantee that the member variables of a class are initialized, you use ____.

constructors

If a function of a class is static, it is declared in the class definition using the keyword static in its ____.

heading

A(n) ____________________ contains the definitions of the functions to implement the operations of an object.

implementation file

Non-static member variables of a class are called the ____________________ variables of the class.

instance

The header file is also known as the ____________________.

interface file

The components of a class are called the ____ of the class.

members

A(n) ____________________ function of a class changes the values of the member variable(s) of the class.

mutator

A(n) ____________________ is a statement specifying the condition(s) that must be true before the function is called.

precondition

By default, all members of a class are ____________________.

private

If a member of a class is ____, you cannot access it outside the class.

private

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. Which of the following variable declarations is correct? a. class rectangleType rectangle; b. rectangle rectangleType; c. rectangle rectangleType.area; d. rectangleType rectangle;

rectangleType rectangle;

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

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 Consider the UML class diagram shown in the accompanying figure. According to the UML class diagram, how many private members are in the class?

three

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?

two

If a class object is passed by ____________________, the contents of the member variables of the actual parameter are copied into the corresponding member variables of the formal parameter.

value


संबंधित स्टडी सेट्स

Statistics Final Study questions

View Set

BUS-101 Test Ch. 7: Management and Leadership

View Set

Business Law 2 - Chapter 24 Intro to Negotiable Instruments

View Set

Chapter 4 Arousal, Stress, Anxiety

View Set

Universal Declaration of Human Right - Summary Articles (1-30)

View Set

2016 SharePoint chapter 3 Lists and Libraries

View Set

PN Adult Medical Surgical Online Practice 2020 A

View Set