The questions of Test_1

with two model answers - one correct (yes) and one incorrect (no)

Mark the correct/incorrect assertions about pointers.
(yes) A pointer denotes the location of a value in memory.
(no) Pointer arithmetic means to add an address to an array pointer.

Mark the correct/incorrect pointer definitions.
(yes) int* p = new int;
(no) int pp = new int;

We have the following variable definitions:

int* ptr1;
int p = 2;
int* ptr2 = new int;
Mark the correct/incorrect assignment statements.
(yes) *ptr1 = p;
(no) p = ptr2;

We have the following variable definitions:

int a[3] = {10, 20, 30};
int* pa = a;
Mark with "yes" expressions which have the value 30.
(yes) a[0] + a[1]
(no) *a

Mark the correct/incorrect definitions and initializations about character pointers and arrays.
(yes) char hello[] = "Hello";
(no) char one[1] = "1";

We have the following classes:

class Point { ... };
class Circle :public Point { ... };
Mark the correct/incorrect assertions about the classes Point and Circle.
(yes) The class Point is the base class and the class Circle is the derived class.
(no) The class Circle is the base class and the class Point is the derived class.

We have the following classes definitions:

class A {
public:
void af();
... };
class B : public A {
public:
void bf();
... };
and objects oa from the class A and ob from the class B. Mark the (syntax) correct/incorrect statements in the body of the main function.
(yes) oa.af();
(no) oa.bf();

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. Which of the following assignments are legal?
(yes) b = d;
(no) d = b;

Mark the correct/incorrect assertions about virtual functions and polymorphism.
(yes) Only member functions can be dynamically bound.
(no) Only nonmember functions can be statically bound.

Mark the correct/incorrect assertions about inheritance hierarchy of stream classes.
(yes) The fstream class derives from iostream.
(no) The fstream class derives from ofstream.

Mark the correct/incorrect assertions about stream classes, objects and member functions.
(yes) An object of istream class is a source of bytes.
(no) The object cin belongs to a class that is derived from ifstream.

We have the following file variables:

ifstream fin;
ofstream fout;
fstream f;
and the variables:
int k = 1;
double x = 5.5;
char ch = 'Y';
string s = "MyString";
Mark the correct/incorrect statements.
(yes) fout << x << " " << s;
(no) fin << "123\n" << x;