SOLUTIONS RATED A+
✔✔What type casting mechanism should be used if you want to change an object of
one class to an object of a different class? - ✔✔dynamic_cast
✔✔Given the following snippet of C++ code:
string name = "Hello";
ifstream myFile;
myFile.open(myFile);
myFile >> name;
myFile.close();
What does it do? A) It loads the word Hello from a file in the file system, or B) It reads a
word from the keyboard. - ✔✔A
✔✔What does the following line of code define?
Days operator++(int) - ✔✔An overloaded operator ++
✔✔What type of values can a throw-statement throw (return)? [object types, primitive
types, string types, all of the above] - ✔✔all of the above
✔✔The exception handling mechanism discussed in this course is at the level of
(hardware, user). - ✔✔user
✔✔In C++, if class B is derived from class A, then without casting, a pointer to a class
(A, B) object can point to a class (A, B) object. - ✔✔A, B
✔✔A virtual member function in C++ implies (early, late) binding between the function
name and the code. - ✔✔late
✔✔Type checking during compilation will prevent a base-class pointer from accessing
the _____ of the derived class object. - ✔✔additional members
✔✔What part of memory can be de-allocated by the destructor? - ✔✔heap memory
created in the constructor
✔✔What part of memory must be de-allocated by an explicit "delete" operation? -
✔✔heap object created in main function
, ✔✔If class B is derived from class A, and x is a protected member of A, in which
classes can x be accessed? (A, B, both, neither) - ✔✔both
✔✔If class B is derived from class A, and two pointers p and q are declared by "A *p; B
*q;" which operation is valid according to polymorphism? A) p = q;, B) q = p;, C) both, or
D) neither - ✔✔A
✔✔If a member function in a class A is defined as a virtual function, then the member
function A) can be re-defined in a derived class, or B) cannot be defined in class A. -
✔✔A
✔✔If the relationship between two classes can be best described as an "is-a" relation,
we should use _____. - ✔✔inheritance
✔✔The class hierarchy of a C++ program is formed according to the A) inheritance
relationship among class, or B) number of data fields in classes. - ✔✔A
✔✔In the C++ exception structure, how many handlers can be defined following each
try-block? - ✔✔zero or more
✔✔What is the function of throw statement? [exit from a _____ and pass a value to the
_____] - ✔✔try-block, catch-block
✔✔What type casting mechanism should be used if you want to cast an integer value to
a double value? - ✔✔static_cast
✔✔What type casting mechanism should be used if you want to change pointer type for
pointing to a different object in an inheritance hierarchy? - ✔✔dynamic_cast
✔✔What is a generic type? A) A type that can take different type of values at the same
time, or B) The type can be determined at run time. - ✔✔B
✔✔Can a multithreading program take a longer time than a single thread program that
solves the same problem? - ✔✔yes
✔✔Why do we need the spin synchronization at the end of a MapReduce process? A)
To improve the performance of multithreading, or B) To make sure that all the threads
complete their tasks - ✔✔B
✔✔"Map and Reduce" is a concept for defining A) generic type, or B) parallel computing
process. - ✔✔B