My test

¡Supera tus tareas y exámenes ahora con Quizwiz!

If a member variable is declared ________, all objects of that class have access to that variable. A) static B) dynamic C) inline D) default E) None of these

A

An actual instance of the function is created in memory when the compiler encounters ________. A) the template prefix B) a call to the template function C) a try block D) a catch block E) None of these

B

An ________ operator can work with programmer-defined data types. A) inline B) unconditional C) overloaded D) undefined E) None of these

C

For the following code, which statement is not true? class Point { private: double y; double z; public: double x; A) x, y, and z are called members of the class. B) The name of the class is Point. C) z is available to code that is written outside the class. D) x is available to code that is written outside the class.

C

If a variable uses more than one byte of memory, for pointer purposes its address is A) the address of the last byte of storage B) the average of all the addresses used to store that variable C) the address of the first byte of storage D) the address of the second byte of storage E) None of these

C

In the following statement, what does int mean?int *ptr = nullptr; A) The variable named *ptr will store an integer value. B) The variable named *ptr will store an asterisk and an integer value C) ptr is a pointer variable and will store the address of an integer variable. D) The variable named *ptr will store the value in nullptr. E) None of these

C

The following statement ________.int *ptr = new int; A) results in a compiler error B) assigns an integer less than 32767 to the variable ptr C) assigns an address to the variable ptr D) creates a new pointer named int E) None of these

C

This directive is used to create an "include guard," which allows a program to be conditionally compiled. This prevents a header file from accidentally being included more than once. A) #include B) #guard C) #ifndef D) #undef E) None of these

C

When you work with a dereferenced pointer, you are actually working with A) a variable whose memory has been allocated B) a copy of the value pointed to by the pointer variable C) the actual value of the variable whose address is stored in the pointer variable D) None of these

C

With pointer variables you can ________ manipulate data stored in other variables. A) never B) seldom C) indirectly D) All of these E) None of these

C

A(n) ________ is used in a function template to specify a generic data type. A) exception B) catch block C) dummy variable D) type parameter

D

How much memory is reserved for a function template? A) four bytes B) eight bytes C) two bytes D) no memory E) None of these

D

The destructor function's return type is ________. A) tilde B) int C) float D) Nothing. Destructors have no return type. E) None of these

D

The following statement ________.cin >> *num3; A) stores the keyboard input in the variable num3 B) stores the keyboard input into the pointer num3 C) is illegal in C++ D) stores the keyboard input into the variable pointed to by num3 E) None of these

D

What does the following statement do?double *num2; A) Declares a double variable named num2 B) Declares and initializes a pointer variable named num2 C) Initializes a pointer variable named num2 D) Declares a pointer variable named num2 E) None of these

D

True/False: An array name is a pointer constant because the address stored in it cannot be changed during runtime.

True

True/False: One purpose that destructor functions are often used for is to free memory that was allocated by the object. True False

True

True/False: The Standard Template Library (STL) contains templates for useful algorithms and data structures. True False

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 False

True

True/False: Using a function template requires less code than overloading a function. True False

True

True/False: When you declare an iterator to work with a container, the compiler automatically chooses the right type. True False

True

True/False: If you do not declare a destructor function, the compiler will furnish one automatically. True False

True

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

True

True/False: More than one constructor function may be defined for a class. True False

True

True/False: Object-oriented programming is centered around the object, which encapsulate together both the data and the functions that operate on the data. True False

True

A class may have this many default constructor(s). A) only one B) more than one C) a maximum of two D) any number E) None of these

A

A function may return a pointer but the programmer must ensure that the pointer A) still points to a valid object after the function ends B) has not been assigned an address C) was received as a parameter by the function D) has not previously been returned by another function E) None of these

A

A function template's prefix contains ________ enclosed in angled brackets. A) one or more generic data types B) the function definition C) constant values D) the function's return type E) None of these

A

All type parameters defined in a function template must appear at least once in the ________. A) function parameter list B) preprocessor directives C) function call D) type.h file E) None of these

A

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? A) myCar.accelerate(); B) Car->accelerate(); C) myCar::accelerate(); D) myCar:accelerate();

A

Assuming ptr is a pointer variable, what will the following statement output?cout << *ptr; A) the value stored in the variable whose address is contained in ptr B) the string "*ptr" C) the address of the variable whose address is stored in ptr D) the address of the variable stored in ptr E) None of these

A

In a function template, the programmer substitutes ________ for ________. A) parameters, data types B) parameters, arguments C) arguments, parameters D) angle brackets, parentheses E) None of these

A

In the following statement: What does the word class indicate? template <class T> A) class is a key word that is used to precede the type parameter T. B) You are deriving a class from an existing class called T. C) You are deriving a class called T from a class called template. D) A class named T will automatically be created by the compiler. E) None of these

A

Members of a class object are accessed with the ________. A) dot operator B) cin object C) extraction operator D) stream insertion operator E) None of these

A

Not all arithmetic operations can be performed on pointers. For example, you cannot ________ or ________ pointers. A) multiply, divide B) +=, -= C) add, subtract D) increment, decrement E) None of these

A

Objects in an array are accessed with ________, just like any other data type in an array. A) subscripts B) parentheses C) #include statements D) output format manipulators E) None of these

A

The process of object-oriented analysis can be viewed as the following steps: A) Identify objects, then define objects' attributes, behaviors, and relationships B) Define data members and member functions, then assign a class name C) Declare private and public variables, prototype functions, then write code D) Write the main() function, then determine which classes are needed E) None of these

A

This operator may be used to assign one object to another. A) = B) == C) <> D) @ E) None of these

A

This type of member function may be called from a statement outside the class. A) public B) private C) undeclared D) global E) None of these

A

Two types of container classes in the STL are: A) sequence and associative B) box and cylinder C) array and struct D) constant and literal E) None of these

A

What is the output of the following program? class TestClass { private: int val; void showVal() {cout << val << endl; } public: TestClass (int x) {val = x; } }; int main() { TestClass test(77); test.showVal(); return0; } A) The program will not compile. B) 77 C) 0 D) The program runs, but with no output.

A

What will the following code output?int number = 22;int *var = &number;cout << var << endl; A) the address of number B) 22 C) an asterisk followed by 22 D) an asterisk followed by the address of number

A

When using an object pointer, use the ________ to access its members. A) -> operator B) <> operator C) dot operator D) & operator E) None of these

A

Which of the following can be used as pointers? A) array names B) numeric constants C) keywords D) None of these

A

The three sequence container objects provided by the STL are: A) set, multiset, map B) vector, deque, list C) map, list, array D) multimap, map, multilist E) None of these

B

A ________ is a member function that is automatically called when a class object is ________. A) destructor, created B) constructor, created C) static function, deallocated D) utility function, declared E) None of these

B

A good reason for overloading an operator is to enable it to ________. A) outperform its C language counterparts B) work in its usual way, but with programmer-defined data types C) operate on more operands than in its standard definition D) operate on no operands E) None of these

B

A pointer variable may be initialized with A) any nonzero integer value B) a valid address in the computer's memory C) an address less than zero D) any nonzero number E) None of these

B

A(n) ________ is a class that stores data and organizes it in some fashion. A) iterator B) container C) template D) box E) None of these

B

Class declarations are usually stored here. A) on separate disk volumes B) in their own header files C) in .cpp files, along with function definitions D) under pseudonyms E) None of these

B

Dynamic memory allocation occurs A) when a new variable is created by the compiler B) when a new variable is created at runtime C) when a pointer fails to dereference the right variable D) when a pointer is assigned an incorrect address E) None of these

B

Each object of a class has its own copy of the class's ________. A) member functions B) member variables C) constructor and destructor functions D) All of these E) None of these

B

Every byte in the computer's memory is assigned a unique A) pointer B) address C) dynamic allocation D) name E) None of these

B

If you do not declare an access specification, the default for members of a class is ________. A) inline B) private C) public D) global E) None of these

B

If you do not furnish one of these, an automatic memberwise copy will be performed when one object is assigned to another object. A) overloaded constructor function B) overloaded assignment operator C) default constructor function D) overloaded copy operator E) None of these

B

Objects are created from abstract data types that encapsulate ________ and ________ together. A) numbers, characters B) data, functions C) addresses, pointers D) integers, floats E) None of these

B

The ________, also known as the address operator, returns the memory address of a variable. A) asterisk (* ) B) ampersand ( & ) C) percent sign ( % ) D) exclamation point ( ! ) E) None of these

B

The algorithms provided by the STL are implemented as ________, and perform various operations on elements of containers. A) virtual functions B) function templates C) global variables D) private data members E) None of these

B

This is used to protect important data. A) public access specifier B) private access specifier C) protect() member function D) class protection operator, @ E) None of these

B

This type of member function may be called only from a function that is a member of the same class. A) public B) private C) global D) local E) None of these

B

What is the output of the following program? class TestClass { TestClass (int x) {cout << x << endl; } TestClass () { cout << "Hello!" <<endl; } }; int main() { TestClass test(77); return0; } A) The program will not compile. B) 77 C) Hello! D) The program runs, but with no output.

B

What will the following code output?int number = 22;int *var = &number;cout << *var << endl; A) an asterisk followed by 22 B) 22 C) an asterisk followed by the address of number D) the address of number

B

What will the following statement output?cout << &num1; A) the value stored in the variable named num1 B) the memory address of the variable named num1 C) the number 1 D) the string &num1 E) None of these

B

When a constructor function accepts no arguments, or does not have to accept arguments because of default arguments, it is called a(n) ________. A) empty constructor B) default constructor C) stand-alone function D) arbitrator function E) None of these

B

When a member function is defined outside of the class declaration, the function name must be qualified with the ________. A) class name, followed by a semicolon B) class name, followed by the scope resolution operator C) name of the first object D) private access specifier E) None of these

B

It is a good idea to make a copy constructor's parameters ________ by specifying the ________ key word in the parameter list. A) inline, inline B) static, static C) constant, const D) global, global E) None of these

C

A function template prefix is placed before the function header. A class template prefix is placed ________. A) following the public: access specification B) following the private: access specification C) before the class declaration D) before the class constructor function header E) None of these

C

A(n) ________ informs the compiler that a class will be declared later in the program. A) static function B) private data member C) forward declaration D) object conversion E) None of these

C

After the code shown executes, which of the following statements is TRUE?int numbers[] = {0, 1, 2, 3, 4};int *ptr = numbers;ptr++; A) ptr will hold the address of numbers[0] B) ptr will hold the address of the second byte within the element numbers[0] C) ptr will hold the address of numbers[1] D) this code will not compile

C

An associative container uses ________ to access elements rapidly. A) data B) functions C) keys D) complex sort algorithms E) None of these

C

Assuming that Rectangle is a class name, the statement: A) declares an object of class Rectangle B) assigns the value of *BoxPtr to the object Rectangle C) declares a Rectangle pointer variable called BoxPtr D) is illegal in C++ E) None of these

C

Examples of access specifiers are the key words: A) near and far B) opened and closed C) private and public D) table and row E) None of these

C

In the following statement:What does T represent? template < class T > A) the name of the function template B) "T" stands for "Template" C) a generic data type that is used in a function template D) the int data type E) None of these

C

Object composition is useful for creating this type of relationship between classes. A) friend B) static C) has a D) conditional E) None of these

C

The beginning of a function template is marked by a ________. A) return type B) parameter list C) template prefix D) semicolon E) None of these

C

The constructor function always has the same name as ________. A) the first private data member B) the first public data member C) the class D) the first object of the class E) None of these

C

This is a "generic" function that can work with any data type. A) function argument B) function parameter C) function template D) member function E) None of these

C

This is automatically called when an object is destroyed. A) constructor function B) specification deallocator C) destructor function D) coroner function E) None of these

C

Use the delete operator only on pointers that were A) never used B) not correctly initialized C) created with the new operator D) dereferenced inappropriately E) None of these

C

What will the following code output? int *numbers =new int[5]; for( int i =0; i <= 4; i++) *(numbers + i) = i; cout << numbers[2] <<endl; A) 0 B) 1 C) 2 D) 3 E) five memory addresses

C

When a class contains an instance of another class, it is known as ________. A) object overloading B) operator overloading C) object composition D) dynamic composition E) None of these

C

When the body of a member function is defined inside a class declaration, it is said to be ________. A) static B) global C) inline D) conditional E) None of these

C

When the less than operator (<) is used between two pointer values, the expression is testing whether A) the value pointed to by the first is less than the value pointed to by the second B) the value pointed to by the first is greater than the value pointed to by the second C) the address of the first variable comes before the address of the second variable in the computer's memory D) the first variable was declared before the second variable E) None of these

C

Which of the following is TRUE about this statement?sum += *array++; A) This statement is illegal in C++. B) This statement will cause a compiler error. C) This statement assigns the dereferenced pointer's value, then increments the pointer's address. D) This statement increments the dereferenced pointer's value by one, then assign that value. E) None of these

C

Which of the following statements deletes memory that has been dynamically allocated for an array? A) int array = delete memory; B) int delete[ ]; C) delete [] array; D) new array = delete; E) None of these

C

void updateObj(MyObj & obj); The function prototype above supports call by value call by reference call by constant reference call by rvalue reference

Call by reference

MyClass A = B; Assume B is of type MyClass and that it has been defined. The code above results in a call to the default constructor move constructor copy constructor copy assignment

Copy constructor

A C++ class is similar to one of these. A) inline function B) header file C) library function D) structure E) None of these

D

A pointer variable is designed to store A) any legal C++ value B) only floating-point values C) an integer D) a memory address E) None of these

D

A(n) ________ is like a pointer. It is used to access the individual data elements in a container. A) element access operator B) subscript indicator C) global data finder D) iterator E) None of these

D

Class templates allow you to create one general version of a class without having to ________. A) write any code B) use member functions C) use private members D) duplicate code to handle multiple data types E) None of these

D

In OOP terminology, an object's member variables are often called its ________, and its member functions are sometimes referred to as its behaviors, or ________. A) values, morals B) data, activities C) attributes, activities D) attributes, methods E) None of these

D

In a procedural program, you typically have ________ stored in a collection of variables, and a set of ________ that perform operations on the data. A) numbers, arguments B) parameters, arguments C) strings, operators D) data, functions E) None of these

D

What is the output of the following program? class TestClass { TestClass (int x) {cout << x << endl; } TestClass () { cout << "Hello!" <<endl; } }; int main() { TestClass test; return0; } A) The program runs, but with no output. B) 0 C) The program will not compile. D) Hello!

D

When you overload an operator, you cannot change the number of ________ taken by the operator. A) arguments B) parameters C) operations D) operands E) None of these

D

Which of the following statements displays the address of the variable numb? A) cout << numb; B) cout << *numb; C) cin >> &numb; D) cout << &numb; E) None of these

D

When objects contain pointers, it is a good idea to create an explicit ________ function. A) destructor B) copy constructor C) static constructor D) inline constructor E) A and B

E

True/False: A destructor function can have zero or more parameters. True False

False

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

False

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

False

True/False: Assume the code below is for a class that contains a single int data member (storedVal). MyClass::MyClass(int val = 100) { storedVal = val; } A new zero-parameter constructor may be added to this class. True False

False

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

False

True/False: More than one destructor function may be defined for a class. True False

False

True/False: The ampersand (&) is used to dereference a pointer variable in C++.

False

True/False: The constructor function does not accept arguments. True False

False

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

False

True/False: With pointer variables you can access, but you cannot modify, data in other variables. True False

False

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

False

True/False: You must declare all data members of a class before you declare member functions. True False

False

True/False: You must use the private access specification for all data members of a class. True False

Flase

class SomeClass { public: SomeClass(int val = 0) {value=new int; *value = val;} int getVal(); void setVal(int); private: int *value; }; Consider the above class declaration. What is true in this case? The class must have the Big 5 functions defined. The class only requires a custom destructor. The classes's move functions must be defined, but its assignments functions are fine. The class is fine as it is.

The class must have the Big 5 function defined

True/False: One purpose that constructor functions are often used for is to allocate memory that will be needed by the object. True False

True

True/False: A pointer can be used as a function argument, giving the function access to the original argument.

True

True/False: A private member function is useful for tasks that are internal to the class, but is not directly called by statements outside the class. True False

True

True/False: A sequence container organizes data in a sequential fashion, similar to an array. True False

True

True/False: Assuming myValues is an array of int values, and index is an int variable, both of the following statements do the same thing. cout << myValues[index] << endl; cout << *(myVaules + index) << endl;

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 False

True

True/False: Consider the following statement: int & a; The above statement results in an error. True False

True


Conjuntos de estudio relacionados

Physical and Health Assessment Final

View Set

History of Rock & Roll: EXAM 2 Songs

View Set

Chapter 5 : Legal Fees, Timekeeping and Billing

View Set