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



Is the following relation true?

(yes) "Harry" < "Hurry"

(no)  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 mark(int n, int& m);

Mark the correct/incorrect statements. Suppose that the integer variable comma is defined and its current value is 0.

(yes) cout << mark(10, comma);

(no)  cout <<
mark(ind, 2);


We have the following function definition:

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

Does the statement prints out an even number?

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



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

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



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 propositons 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.