The main abstractions of the Standard Template Library include which of the following?
Iterators Exception handlers Algorithms (d) I and III only The nodes of a _____ linked list can be traversed _____. (a) singly, forward only The class vector in the C++ STL contains which of the following methods?
push_back push_front pop_front (b) I only The asymptotic running time that most closely bounds the performance of a selection sort on an input array with length n is (c) O(n2) The time to perform depth first search, starting at the first vertex of a graph with n vertices and e edges implemented as an adjacency list has what order? (d) O(n + e)
Typical divide and conquer algorithms use _____ to divide a problem into smaller sub-problems. The _____ typically solve(s) these sub-problems directly. (c) recursive function calls, base case of the recursion The STL deque container contains which of the following methods?
push_back push_front pop_front (d) I, II, and III The size of an STL vector is defined to be the (d) number of elements currently stored in the vector The STL is heavily based on (c) templates The capacity of an STL vector is defined to be the (b) maximum number of elements that can be stored in the vector without resizing To indicate the end of the list, the final node in a typical singly-linked list stores _____ in place of a _____. (c) a null pointer, pointer to the next node Typical implementations for which of the following STL containers store elements contiguously in memory?
vector list (c) I only To access an element in a singly linked list, a program must (b) traverse all nodes in the list prior to that element To read data from a file into a C++ program using class ifstream, it is necessary to include the _____ library header file.
(a) fstream To which of the following is object-based programming ideally suited? (d) Encapsulation
U
Under what circumstances will a member function in C++ display polymorphic behavior? (b) If and only if the function is explicitly declared to be virtual Using a backtracking technique to solve a problem typically involves (d) pursuing a possible solution until it is found to be a solution or a non-solution
V
Valid comments in C++ include which of the following?
/* comment */ / comment // comment (c) I and III only W
Which of the following declares p to be a pointer to an integer? (a) int *p; Which of the following statements creates p as an alternative name for the variable i? (d) int &p = i;
What is the role of the destructor for the base class when an instance of a derived class goes out of scope? (a) It is called automatically. Which of the following expressions evaluates to true in C++ if and only if the index variable i is in bounds for an array of size 10? (a) 0 <= i && i < 10 Which of the following statements about C++ is (are) true
It is strongly typed. It has been standardized by ISO. (b) I and II What is the type name used to represent single characters in C ++? (a) char Which of the following is true about a class without a (user-defined) constructor? (d) It may have a destructor, but might not. What is the type name used to represent extra precision real numbers in C ++? (b) double Which of the following statements might be produced by the decomposition of a problem into objects and relationships?
"A is a type of B" "A B contains a C" (d) I and II Which of the following is not a predefined stream object in C ++? (a) cfile Which of the following lists of C++ types are ordered increasingly by size, as computed by sizeof()? (c) char, short, int, long Which of the following is the C++ preprocessor directive for file inclusion? (a) #include Which of the following is true about variables with dynamic extent? (c) They are created and destroyed by the programmer. Which of the following statements properly allocates an array of 100 integers? (b) int *A = new int[100]; Which of the following statements is true about a reference used as a function parameter? (c) It allows a function to modify the original object passed in as the argument. Which of the following statements creates p as an alternative name for the variable i? (d) int &p = i; Which of the following C++ operators is the dereference operator? (d) * Which of the following C++ operators is the address-of operator? (a) & What is the effect of the following C++ code fragment?
int A[100]; for(int *p = A; p < A + 100; ++p) { *p = 0; } (a) It zeroes out the 100 elements of array A. Which of the following is true about the default parameter passing mechanism in C++? (a) It is call-by-value. What, if anything, is wrong with the following C++ code fragment?
bool *bp; int x; bp = &x; (d) A pointer to an int cannot be assigned to a variable that is a pointer to a bool. Which of the following declares p to be a pointer to an integer? (b) int *p; What, if anything, is wrong with the following code fragment?
Thing *ptr = new Thing; ptr = NULL;
(a) When executed, it will create an instance of Thing and then remove the only reference to this instance without destroying it first. Which of the following operations are valid for C++ pointer arithmetic?
Addition Subtraction Multiplication (b) I and II only Which of the following statements is true about a reference used as a function parameter?
(a) It allows a function to modify the original object passed in as the argument. Which of the following is true about the default parameter passing mechanism in C++? (c) It is call-by-value. Which of the following statements creates p as an alternative name for the variable i?
(b) int &p = i; What, if anything, is wrong with the following C++ code fragment?
bool *bp; int x; bp = &x; (a) A pointer to an int cannot be assigned to a variable that is a pointer to a bool. What is the effect of the following C++ code fragment?
int A[100]; for(int *p = A; p < A + 100; ++p) { *p = 0;} (c) It zeroes out the 100 elements of array A.
Which of the following declares p to be a pointer to an integer? (a) int *p; Which of the following is true of inheritance? (b) It provides for the elegant construction of a new class from an existing class. Which of the following describes a difference between template functions and template classes in C++? (c) The compiler determines the types of a template function's arguments, but the types of template classes must be stated explicitly when declaring objects. Which of the following is true about the run-time efficiency of using template functions versus using nontemplate functions? (b) The run-time efficiency is the same for both. Which of the following is an example of a pure virtual function? (b) virtual int Compute() = 0; What is the role of the destructor for the base class when an instance of a derived class goes out of scope? (c) It is called automatically. Which of the following is (are) true about template classes in C++?
Methods cannot be overloaded in templated class definitions. Private data of a templated class cannot be declared to have the type of the templated parameter. (a) None Which of the following is necessary in order to obtain polymorphic behavior in C ++? (b) Pointers or references are used with virtual functions. What is composition? (c) It is the inclusion of one class in another as a data member. Which of the following statements regarding the design of the Standard Template Library (STL) in C++ is (are) true?
Each STL algorithm is usable with one specific container. The STL does not use templates and instead relies on polymorphism. (a) None Which of the following is true of inheritance? (a) It causes one type to behave like several types. Which of the following describes a difference between template functions and template classes in C++?
(d) The compiler determines the types of a template function's arguments, but the types of template classes must be stated explicitly when declaring objects. Which of the following data structures is not a container implemented in the C++ Standard Template Library? (b) Hash table Which of the following statements is (are) true of typical implementations of vectors and deques?
A vector's implementation uses one array, whereas a deque's implementation uses multiple arrays. Insertions at the front of a deque tend to be more efficient than insertions at the front of a vector. (a) I and II Which of the following statements is (are) true regarding strings in C++?
Strings in C++ are supported by the standard class string. A constructor for the class string can accept a C-style string as an argument. (c) I and II Which of the following statements is (are) true regarding C-style strings?
They are terminated by the null character. Storing a five-character string requires at least seven characters. (b) I only Which of the following is (are) typically managed using a stack?
Implementation of function calls in a procedural programming language Evaluating arithmetic expressions, taking precedence rules into account Handling jobs sent to a printer, and ensuring that the first jobs to be submitted are printed first (c) I and II only Which of the following data structures uses a "Last-in, First-out" policy for element insertion and removal? (c) Stack Which of the following is not a basic operation that can be performed on a queue? (d) Inserting an item into the second position of the queue
|