Computer Science II Test 2

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

This operator may be used to assign one object to another.

=

True/False: You may overload any C++ operator, and you may use the operator function to define non-standard operators, such as @ and ^.

False

True/False: A static member function does not need to be called by a specific object of the class.

True

True/False: A static member variable can be used when there are no objects of the class in existence.

True

True/False: By default, when an object is assigned to another, each member of one object is copied to its counterpart in the other object.

True

True/False: It is possible to declare an entire class as a friend of another class.

True

It is a good idea to make a copy constructor's parameters ________ by specifying the ________ key word in the parameter list.

constant, const

In C++11 you can have one constructor call another constructor in the same class by using

constructor delegation

A ________ is a member function that is automatically called when a class object is ________.

constructor, created

This is a special function that is called whenever a new object is created and initialized with another object's data.

copy constructor

When objects contain pointers, it is a good idea to create an explicit ________ function.

copy constructor

A class is a(n) ________ that is defined by the programmer.

data type

When you redefine the way a standard operator works when it is used with class objects, you have ________ the operator.

overloaded

A member function that is declared ________ may not access any non-static data members in the class.

static

If a member variable is declared ________, all objects of that class have access to that variable.

static

This type of member variable may be accessed before any objects of the class have been created.

static

A C++ class is similar to a(n)

structure

Objects in an array are accessed with ________.

subscripts

The constructor function always has the same name as

the class

Which of the following is automatically called when an object is destroyed?

the destructor function

Which of the following is used to protect important data?

the private access specifier

Which of the following is a directive used to create an "include guard" that allows a program to be conditionally compiled to prevent a header file from accidentally being included more than once?

#ifndef

When you dereference an object pointer, use the

-> operator

What is the output of the following program? #include <iostream> using namespace std; class TestClass { public: TestClass (int x) { cout << x << endl; } TestClass( ) { cout << "Hello!" << endl; } }; int main( ) { TestClass test (77); return 0; }

77

True or False? A destructor function can have zero to many parameters.

False

True or False? Class objects can be defined prior to the class declaration.

False

True or False? In-place member initialization no longer is available in C++11.

False

True/False: A non-static member function may not access a static member variable.

False

True/False: A public data member may be declared a friend of a private function.

False

True/False: C++ permits you to overload the sizeof operator and the this pointer.

False

True/False: If you overload the prefix ++ operator, the postfix ++ operator is automatically overloaded.

False

True/False: In C++, if you overload the < operator, you must also overload the > operator.

False

True/False: When a class declares an entire class as its friend, the friendship status is reciprocal. That is, each class's member functions have free access to the other's private members.

False

True/False: When you overload the << operator, you must also overload the >> operator.

False

True/False: You can overload the conditional operator to make it function as an unconditional operator.

False

What is the output of the following program? #include <iostream> using namespace std; class TestClass { public: TestClass (int x) { cout << x << endl; } TestClass( ) { cout << "Hello!" << endl; } }; int main( ) { TestClass test; return 0; }

Hello!

True or False? In object-oriented programming, the object encapsulates both the data and the functions that operate on the data.

True

True or False? Whereas object-oriented programming centers on the object, procedural programming centers on functions.

True

True/False: The this pointer is a special built-in pointer that is automatically passed as a hidden argument to all non-static member functions.

True

True/False: The this pointer is automatically passed to non-static member functions of a class.

True

True/False: When you overload an operator, you can change the operator's original meaning to something entirely different.

True

If you do not furnish one of these a default will be provided for you by the compiler. A. Copy Constructor B. Constructor C. Destructor D. All of these E. None of these

all of these

In OOP terminology, an object's member variables are often called its ________ and its member functions can be referred to as its behaviors or its ________.

attributes, methods

When a constructor has a member initialization list, the initializations take place

before any statements in the body of the constructor execute

When a member function is defined outside of the class declaration, the function name must be qualified with the

class name, followed by the scope resolution operator

In a procedural program you typically have ________ stored in a collection of variables and a set of ________ that perform operations on the data.

data, functions

Objects are created from abstract data types that encapsulate ________ and ________ together.

data, functions

When a constructor function accepts no arguments, or does NOT have to accept arguments because of default arguments, it is called a(n)

default constructor

Members of the class object are accessed with the

dot operator

In the following function header: FeetInches FeetInches: :operator++(int) the word (int) is known as a(n):

dummy parameter

A(n) ________ informs the compiler that a class will be declared later in the program.

forward declaration

This type of function is not a member of a class, but it has access to the private members of the class.

friend

Object composition is useful for creating this type of relationship between classes.

has a

Where are class declarations usually stored?

in their own header files

In C++11 you can use ________ to initialize a member variable in its declaration statement.

in-place initialization

The following code shows an example of ________ class Point { private: double y = 5.70; double z = 3.0; public: (Public member functions go here...) };

in-place initialization

When the body of a member function is defined inside a class declaration, it is said to be

inline

Each object of a class has its own copy of the class's ________.

member variables

Assume that myCar is an instance of the Car class and that the Car class has a member function named accelerate. Which of the following is a valid call to the accelerate member function?

myCar.accelerate();

The constructor function's return type is A. Int B. Float C. Char D. Structure Pointer E. None of these

none of these

The destructor function's return type is

nothing; destructors have no return type

When a class contains an instance of another class, it is known as ________.

object composition

How many default constructors can a class have?

only one

When you overload an operator, you cannot change the number of ________ taken by the operator.

operands

To overload the + operator, you would write a function named ________.

operator +

An ________ operator can work with programmer-defined data types.

overloaded

If you do not furnish one of these, an automatic memberwise copy will be performed when one object is assigned to another object.

overloaded assignment operator

If you do NOT declare an access specification, the default for members of a class is

private

Which type of member function may only be called from a function that is a member of the same class?

private

Examples of access specifiers are the key words

private and public

The type of member function that may be called from a statement outside the class is

public

C++ requires that a copy constructor's parameter be a(n) ________.

reference object

If a local variable and a global variable have the same name within the same program, the ________ resolution operator must be used.

scope

A reason to overload the ________ is to write classes that have array-like behaviors.

square brackets [ ] operator

C++ allows you to redefine the way ________ work when used with class objects.

standard operators

What is the output of the following program? #include <iostream> using namespace std; class TestClass { private: int val; void showVal( ) { cout << val << endl; } public: TestClass(int x) { val = x; } }; int main( ) { TestClass test (77); test.showVal( ); return 0; }

the program will not compile

Assuming that Rectangle is a class name, what can you say is TRUE, given the following statement?

the statement defines a Rectangle pointer variable named *BoxPtr

This is a special built-in pointer that is available to a class's member functions.

this pointer

A good reason for overloading an operator is to enable it to ________.

work it its usual way, but with programmer-defined data types

For the following code, which statement is NOT true? class Point { private: double y; double z; public: double x; };

z is not available to code that is written outside the class


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

A közigazgatás fogalma, jellemzői, szervezete

View Set

Chp 9 reproductive 10 emotion 11 ingestive

View Set

E-business Management- Ch.9 Online Retail and Services

View Set

All GAVS Physics Quizzes and Tests

View Set

Digital Forenesics Cengage 13-1 Lab

View Set

Ch. 16 Gene Regulation in Eukaryotes

View Set

Missouri Constitution: House, Senate, both, or neither?

View Set

Biology - Ch. 6 - Inquizitive EC

View Set

Chapter 6 Learnsmart b*tch are you dumb or are you dumb

View Set