In the class interface from the previous question which of


Question 1: Which of the following C++ statements uses object-oriented programming?

a) for(int i = 0; i < 10; i++);

b) x = 5;

c) int *numbers = new int[10];

d) Mario.draw();

e) None of the above

Question 2: Consider the following class interface. Which of the functions is the default constructor?

1 2 3 4 5 6 7

classLibrary

{public:

Library();

Library(intnumBooks);

Library(constLibrary&other);};

a) Library();

b) Library(int numBooks);

c) Library(const Library &other);

d) All of the above

e) None of the above

Question 3: In the class interface from the previous question, which of the functions is the copy constructor?

a) Library();
b) Library(int numBooks);
c) Library(const Library &other);
d) All of the above
e) None of the above

Question 4: Which of the following C++ statements declares a Student object and initializes it with the value "Luke"?

a) Student Luke;
b) Student = "Luke";
c) Student s("Luke");
d) All of the above
e) None of the above

Question 5: Consider the following snippet of C++ code. Which of the following C++ statements uses dynamically allocated memory?

1 2 3

intx=5;

int*y=newint;

*y=5;


a) int *z = &x;

b) int &r = x;

c) int p = *y;

d) All of the above

e) None of the above

Question 6: Consider the following snippet of C++ code. Which statement causes a memory leak?

1 2 3 4 5 6

chara='!';

char*b=newchar;

char&c =*b;

char*d=&a;

char*e=newchar[12];

deleteb;

a) char a = '!';

b) char *b = new char;

c) char &c = *b;

d) char *d = &a;

e) char *e = new char[12];

f) delete b;

Question 7: In the previous question's snippet, which of the following C++ statements would fix the memory leak if added at the end?

a) a = NULL;
b) delete a;
c) delete d;
d) d = NULL;
e) delete[] e;

Question 8: Which of the following C++ statements correctly prints out the value of the first element in the array below? C++

1 2

int*array=newint[5];

array[0]=5;

a) cout << array[0] << endl;
b) cout << *array << endl;
c) cout << *(array + 0) << endl;
d) All of the above
e) None of the above

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: In the class interface from the previous question which of
Reference No:- TGS01481068

Now Priced at $10 (50% Discount)

Recommended (96%)

Rated (4.8/5)