Final
test
Mark the correct/incorrect assertions about Sorting and Searching.
(yes) Selection sort is based upon finding the minimum value in a range
of indexes and placing that value at the front of the vector.
(no) Linear search is an O(log
n) algorithm.
Can the following line be a definition of the destructor of a class?
(yes) Department::~Department()
{}
(no) Dep::~Dep(int i) { cout
<< i; }
Is it possible to overload the next operators for objects of the
well-known
class Time, using the
given nonmember function declaration?
(yes) long operator-(Time,
Time);
(no) Time operator+();
Mark the correct/incorrect statements about Templates and Operator
Overloading.
(yes) A class template is a mechanism that allows us to create classes
whose data fields have arbitrary type.
(no) The function Time&
operator++(Time&) overloads postfix
increment operator for Time objects.
Mark the correct/incorrect pointer
definitions.
(yes) int* pint = new int;
(no) int pin = new int;
Mark with "yes" the case(s) when the output sequence of digits
corresponds to the input number.
int dig(int n)
{ cout << n;
if (n > 9) return
dig(n/10) + 1;
else return 1;
}
int main()
{ int k; cin >> k;
cout << dig(k);
return 0;
}
The notation is: <input
number> -> <output sequence><int>We have the following code fragment:
void fun3() { throw
runtime_error("RTE" ); }
void fun2() throw(runtime_error)
{ ... }
void fun1() throw(runtime_error)
{ fun2(); }
int main()
{ try { fun1(); }
catch (runtime_error e) {
cout << e.what(); }
return 0;
}
Replacing ... with the
given below statement, the message RTE prints on the screen.
Is this assertion true?
(yes) fun3();
(no) fun1();