CS 162 Lecture Notes - Lecture 23: Iterator, Virtual Function, Standard Template Library
CS 162 – Lecture 23 – Exam II Review
True or False Questions
o Pointers to a base class may be assigned the address of a derived class object
▪ True
o In C++ polymorphism is very difficult to achieve unless you also use inheritance
▪ True
o You can create a non-member function with one parameter that overloads the
relational equal to (==) operator
▪ False
o The standard template library (STL) vector and list classes are examples of
sequential containers
▪ True
o Nodes in a linked list are stored in contiguous memory
▪ False
o C++ enables you to use the friend keyword to declare friend functions and friend
classes for a class so these functions and classes can access the class’s private
members.
▪ True
o If a function is declared as a returnType functionName(parameterList) throw
(type), this function can only throw the exception of the specified type
▪ True
o A template class allows the class to be used with different data types
▪ True
o If an exception is not caught, it is stored for later use
▪ False
o The following code declares a vector of characters
▪ Vector characters<char>;
• False
o Destructors are not inherited into the derived class
find more resources at oneclass.com
find more resources at oneclass.com
▪ True
o The assignment operator is inherited from the base class
▪ False
o If a function throws an exception, it must be caught inside that function
▪ False
o In a try block, the throw statement is always executed
▪ False
o The catch block is the group of statements that handle an exception
Multiple Choice Questions
o To add an int value 5 to a vector v of integers, use ____
▪ V.append(5);
▪ V.insert(5);
▪ V.add(5);
▪ V.push_back(5);
• Correct
o Who can access private data in a class?
▪ Classes derived from the class
▪ Friends of the class
• Correct
▪ Everyone
▪ A and B
▪ No one
o Which of the following statements are true?
▪ A custom exception class must always be derived from class exception
▪ A custom exception class must always be derived from a derived class of
class exception
▪ A custom exception class is just like a regular class in C++
• Correct
find more resources at oneclass.com
find more resources at oneclass.com