Final test

We have the following classes:
class Employee { ... };
class Manager : public Employee { ... };
Mark the correct/incorrect assertions.
(yes) The class Employee is the base class and the class Manager is the derived class.
(no) The class Manager is the base class and the class Employee is the derived class.


Suppose the class D inherits from B. Let b be an object of the class B, d be an object of the class D, pb be a pointer of the class B and pd be a pointer of the class D. Is the following assignment correct?
(yes) pb = static_cast<B*>(pd); 
(no) d = b;


Mark the correct/incorrect assertions about Recursion.
(yes) Every recursive call must simplify the computation in some way.
(no) In all cases the recursive solution is much slower that its iterative counterpart.


Does the input data correspond to the output data when executing the following program code?
 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 data> -> <output data>
(yes) 122 -> 1221213
(no) 303 -> 3031033


We have the following recursive function:
bool s_is_p(string s, int start, int end)

    if (start >= end) return true;

    if (s[start] == s[end])
      return s_is_p(s, start + 2, end - 2);
   else
      return false;
}
Mark the return value when the function call is
   s_is_p(s, 0, s.length() - 1);
and value of the string s is as follows:
(yes) aaaa
(no) aaaabbbb


We have a linked list and an iterator:
list<int> slist;
list
<int>::iterator lit;
The list contains 10 elements and the iterator points to the second element of the list. Mark correct/incorrect (about syntax or logic) expressions:
(yes) *lit > 0
(no) *lit != *slist.end()


Mark the correct/incorrect assertions about member function definitions of classes Node, List and Iterator, given in the file List2.cpp.
(yes)  In push_back member function: first is a data member of the class List.
(no) In end member function: last is a data member in the class Iterator.


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.


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();


Mark the correct/incorrect assertions about Exception Handling.
(yes) Throwing an Exception means: Abandon current function and throw a value to an exception handler.
(no) A function with throw() specification is allowed to throw any exceptions.