The questions of Test_2
with two possible answers - one correct (yes) and one incorrect (no)


Mark the syntax correct/incorrect C++ statements. Assume that mark is an integer variable.

(yes)if (mark == 1) mark++;
(no) if [mark == 0] mark--;


The expression value is:

(true) "Harry" < "Hurry"

(false)  8 < -5

Mark the correct/incorrect assertions about functions.

(no)
  Each function receives input parameters only from number types.
(yes) Functions need to be defined before they can be used.


We have the following function declaration:

    int joe(int vari, int& refi);

Mark the correct/incorrect function calls in the statements. Suppose that the integer variable xenon is defined and its current value is 0.

(yes) cout << joe(10, xenon);

(no)  cout <<
joe(xenon, 2);

We have the following function definition:

    int three(int n)
    { if (n % 3 > 1) return n;
      else           return n + 1;
    }

Does the statement prints out an even number?

(no)  cout << three(0);
(yes) cout << three(1);

Mark with "yes'' the statements in which the loop body executes exactly once. Suppose that counter is an integer variable and
its current value is 0.

(no) while (counter > 0) counter++;
(yes) while (counter <= 0) counter++;

Mark with "yes'' the program code excerpt where the body of the loop statement executes 3 times exactly.

(yes) i=1; while(i<4) i++;
(no)  i=1; while(i<=4) i++;

Mark the correct/incorrect assertions about classes.

(yes) A constructor always has the same name as the class name.
(no) The main function can access directly the private data fields of a class.

Mark with "yes'' a function declaration which can be used as a constructor of a class.
(Remember that the constructor name coincides with the class name.)

(yes) Point(double x, double y);
(no)  int Time();

We have a class:
class Product {
public:
Product();
Product(string n, double p, int s);
void read();
string get_name() const;
double get_price() const;
void print() const;
private:
string name;
double price;
int score;
};
and an object p of this class, constructed in main function. Mark the correct/incorrect statements in the body of main function.

(yes) Product p22;
(no)  cout << p.name;

Mark the correct/incorrect propositions about the following function definition:

Employee::Employee(string employee_name,
                      int initial_salary)
{  name = employee_name;
   salary = initial_salary; }

(yes) This is a definition of a constructor in the class Employee.
(no) The statement Employee harry; uses the defined above constructor.