Final Exam CS2

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

A generic function that can work with any data type is called an exception template.

False

A member function of a derived class may not have the same name as a member function of a base class.

False

A new node cannot become the first node in the list.

False

A new node must always be made the last node in the list.

False

A non-static member function may not access a static member variable.

False

A program may not contain both a "regular" version of a function and a template version of the function.

False

A stack that is implemented as a linked list is known as a deque.

False

An aggregate class's constructor can use a member initialization list to call the constructors for each of its member objects.

False

C++ permits you to overload the sizeof operator and the this pointer.

False

Deleting an entire list simply requires the use of the delete operator.

False

If there are no nodes in a linked list, you cannot append a node to the list.

False

If you overload the prefix ++ operator, the postfix ++ operator is automatically overloaded.

False

In a mapping, each element must have one of the following two parts: either a key or a value.

False

Nodes in a linked list are stored in contiguous memory.

False

The programmer must declare in advance the size of a dynamic stack or queue.

False

The try/catch/throw construct is able to handle only one type of exception in a try block.

False

The two most common queue operations are push and pop.

False

There is no difference between declaring an object of an ordinary class and an object of a template class.

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

When you create a linked list you must know in advance how many nodes the list will contain.

False

You can overload the conditional operator to make it function as an unconditional operator.

False

A dynamic stack starts as an empty linked list.

True

A function object is an object that acts like a function and is also known as a functor.

True

A linked list can consist of structs, objects, and other abstract data types.

True

A linked list can grow and shrink as a program runs.

True

A mutable iterator gives you read/write access to the element to which the iterator points.

True

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

True

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

True

A vector is an associative container that works like an array but is dynamic in size.

True

An iterator is a function that is used to access items in an array.

True

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

True

In a static stack class, the constructor function can dynamically allocate memory for the stack array.

True

Stacks and queues can be implemented as arrays or linked lists.

True

Static binding occurs when the compiler binds a function call with the function call that resides in the same class as the call itself.

True

The STL provides containers for deque and queue.

True

The STL provides many algorithms which are implemented as function templates and are included in the <algorithm> header file.

True

The try block of a try/catch construct is used to display the definition of an exception parameter.

True

To delete an entire list, normally you must traverse the list, deleting each node, one by one.

True

When arguments must be passed to the base class constructor, they are passed from the derived class constructor's header line.

True

When you overload an operator, you can change the operator's original meaning to something entirely different

True

You can use the name of a function to get that function's address in memory and, therefore, get a function pointer to point to the function's executable code.

True

To retrieve a value from a map, you call the __________ member function and pass the __________ that is associated with the desired value. a. at(), key b. at(), value c. key(), key d. pair(), key e. None of these

a. at(), key

What does the word class indicate in the following statement? template < class T > a. class is a key word that is used to precede the type parameter. b. It indicates that a class is being derived from an existing class named T. c. It indicates that a class named T is being derived from a class named template. d. A class named T will automatically be created by the compiler. e. None of these

a. class is a key word that is used to precede the type parameter.

Catch blocks serve as a. exception handlers b. receivers c. temporary variables d. permanent storage for trapped errors e. None of these

a. exception handlers

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. function parameter list

When an element is stored in a map, it is stored as an object of the __________ type. a. map b. key c. pair d. key_value e. None of these

a. map

When a derived class has two or more base classes, the situation is called a. multiple inheritance b. multiplicity c. polymorphism d. encapsulation e. None of these

a. multiple inheritance

When the __________ operator fails to allocate memory, C++ throws a bad_alloc exception. a. new b. alloc c. catch d. None of these

a. new

A function template's prefix contains __________ enclosed in angle 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. one or more generic data types

In a function template, the programmer substitutes __________ for __________. a. parameters, data types b. parameters, arguments c. arguments, parameters d. data types, parentheses e. None of these

a. parameters, data types

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. sequence and associative`

If a member 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. static

In an insertion or deletion routine: how many pointers are you required to create for use during the traversal process? a. two: one for the node under inspection and one for the previous node b. two: one for the node under inspection and one for the next node c. one: for the node being inserted or deleted d. three: one for the node under inspection, one for the next node, and one for the following node

a. two: one for the node under inspection and one for the previous node

Select all that apply. Which of the following statement(s) is(are) not true? a. A map is an associative container. b. Each element in a map has two parts. c. Map elements are usually referred to as key-value pairs. d. The key value in a map is used to locate a value. e. The value element in a map is used to locate the key.

b. Each element in a map has two parts. e. The value element in a map is used to locate the key.

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. a call to the template function

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. container

The __________ destructor is called before the __________ destructor. a. base, derived b. derived, base c. public, private d. private, public e. None of these

b. derived, base

Multiple inheritance is when a __________ class has __________ base classes. a. base, no b. derived, two or more c. derived, no d. compound, more than two e. None of these

b. derived, two or more

If an exception is thrown by a member function of a class object, the class __________ is called. a. constructor b. destructor c. catcher d. handler e. None of these

b. destructor

Two primary queue operations are a. push and pop b. enqueue and dequeue c. insert and delete d. onqueue and offqueue e. None of these

b. enqueue and dequeue

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. function templates

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. member variables

Because a vector container uses a dynamically allocated array to hold its elements, it is common for the vector class to allocate a. less memory than it needs b. more memory than it needs c. a separate memory location for copies of new elements d. None of these

b. more memory than it needs

An iterator of the iterator type that gives you read/write access to the element to which the iterator points is known as a(n) a. immutable iterator b. mutable iterator c. auto iterator d. range iterator e. None of these

b. mutable iterator

To overload the + operator, you would write a function named a. overload + b. operator + c. function + d. operator.overload(+) e. None of these

b. operator +

A __________ is used to travel through a linked list and search for data. a. node b. pointer c. null pointer d. traversal operator e. None of these

b. pointer

A linked list class must take care of removing the dynamically allocated nodes and this is done by a. the constructor function b. the destructor function c. overriding the removal function d. overloading the memory persistence operator e. None of these

b. the destructor function

The process of moving through a linked list is referred to as __________ the list. a. cruising b. traversing c. hopping d. revising e. None of these

b. traversing

The __________ starts with the key word try and is followed by a block of code that executes any statement that might cause an exception to be thrown. a. try block b. try/catch class c. try function d. catch function e. None of these

b. try/catch class

To handle an exception that has been thrown, a program must have a(n) a. throw function b. try/catch construct c. fatal error d. unrecoverable error e. None of these

b. try/catch construct

How many steps are involved in the process of deleting a node? a. one: delete the node from memory b. two: remove the node without breaking links, then delete it from memory c. three: create a blank node, remove the node being deleted, insert the blank node d. four: create a blank node, insert the blank node before the node being deleted, remove the node being deleted, delete the blank node e. None of these

b. two: remove the node without breaking links, then delete it from memory

The three sequence container objects provided by the STL are a. set, multiset, and map b. vector, deque, and list c. map, list, and array d. multimap, map, and multilist e. None of these

b. vector, deque, and list

What does the T represent in the following statement? 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. a generic data type that is used in a function template

The advantage a linked list has over a vector is that a. a linked list can dynamically shrink or grow and a vector cannot b. a linked list is smaller than a vector c. a node can be inserted or removed faster from a linked list than from a vector d. data removal and insertion are more accurate with a linked list than with a vector e. None of these

c. a node can be inserted or removed faster from a linked list than from a vector

Which of the following defines an array object that holds three strings? a. array<int, 3> items = {blue, green, yellow} b. array<strings, 4> items = {'blue', 'green', 'yellow',} c. array<string, 4> items = {"blue", "green", "yellow"} d. array<4> string items {"blue", "green", "yellow"} e. None of these

c. array<string, 4> items = {"blue", "green", "yellow"}

The most important data structures in the STL are __________ a. arrays and structures b. lists and groups c. containers and iterators d. templates and prototypes e. None of these

c. containers and iterators

A(n) __________ is a special function that is called whenever a new object is created and initialized with another object's data. a. static function b. destructor c. copy constructor d. assignment function e. None of these

c. copy constructor

A generic function that can work with any data type is a a. function argument b. function parameter c. function template d. member function e. None of these

c. function template

An associative container uses __________ to access elements rapidly. a. data b. functions c. keys d. complex sort algorithms e. None of these

c. keys

The vector class has a ________ member function which can be used to request an increase in the vector's capacity and a __________ member function to decrease a vector's capacity. a. size(), max_size() b. capacity(), reserve() c. max_size(), shrink() d. reserve(), shrink_to_fit() e. None of these

c. max_size(), shrink()

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. object composition

C++11 introduced the __________ key word to help prevent subtle errors when overriding virtual functions. a. const b. final c. override d. virtual e. None of these

c. override

Protected members of a base class are like __________, but they may be accessed by derived classes. a. constructor functions b. static members c. private members d. public members e. None of these

c. private members

The __________ constructor is called before the __________ constructor. a. base, derived b. derived, base c. public, private d. private, public e. None of these

c. public, private

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. template prefix

If the head pointer points to nullptr, this indicates a. the list has been previously created and then destroyed b. the list needs to be destroyed c. there are no nodes in the list d. the list is full and cannot accept any new nodes e. None of these

c. there are no nodes in the list

A sequence container that is dynamic in size is a(n) a. array b. map c. vector d. multimap e. None of these

c. vector

Multiple inheritance opens the opportunity for a derived class to have ___________ members. a. dynamic b. private c. public d. ambiguous e. None of these

d. ambiguous

An exception thrown from outside a try block will a. be caught outside the catch block b. be caught inside the catch block c. remain inside the throw block d. cause the program to abort execution e. None of these

d. cause the program to abort execution

The compiler performs __________ on virtual functions. a. local binding b. additional error checking c. static binding d. dynamic binding e. None of these

d. dynamic binding

Appending a node means adding it to the end of a list, and __________ a node means putting a new node in the list, but not necessarily at the end. a. concatenating b. popping c. clamping d. inserting e. None of these

d. inserting

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. iterator

How much memory is reserved for a function template? a. four bytes b. It depends on the size of the template. c. two bytes d. no memory e. None of these

d. no memory

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. operands

The __________ member variable may be accessed before any objects of the class have been created. a. private b. public c. inline d. static e. None of these

d. static

To create a linked list you must first create a(n) a. header file b. function template c. exception d. struct e. None of these

d. struct

A doubly linked list keeps track of the next node in the list as well as a. itself b. the head node c. the tail node d. the previous node e. None of these

d. the previous node

A(n) __________ is used in a function template to specify a generic data type. a. dummy variable b. exception c. catch block d. type parameter e. None of these

d. type parameter

Functions that are dynamically bound by the compiler are __________ functions. a. constructor b. destructor c. static d. virtual e. None of these

d. virtual

A __________ of a base class expects to be overridden in a derived class. a. constructor function b. destructor function c. static function d. virtual function e. None of these

d. virtual function


Kaugnay na mga set ng pag-aaral

Which of the following statements are true of the horizontal motion of projectiles? List all that apply.

View Set

Network Operations (3.0) study set

View Set

204 PrepU Chapter 51: Assessment and Management of Patients With Diabetes

View Set

English 10 Provincial Terms & Definitions

View Set

Body Shapes (Hour, Apple, Pear, Inverted Triangle, Rectangle)

View Set