Question: Please help with a couple quick and easy questions. Any explaination would be greatly appreciated. 1) If you do not write one of these, a

Please help with a couple quick and easy questions. Any explaination would be greatly appreciated.

1) If you do not write one of these, a default will be provided for you by the compiler.

a) copy constructor

b) constructor

c) destructor

d) All of these

None of these

2) A class member that is to be shared among all objects of a class is called

a) A constant member

b) A reference member

c) A static member

d) A function member

3) Which of the following is correct syntax to declare C++ class B to be a public base class for

derived class D

public base class B: class D {/**/};

class D : public class B {/* */};

class D : public B {/* */};

class B: public D { };

None of the above

4) ________ members of a base class are never accessible to a derived class.

A) Public

B) Private

C) Protected

D) A, B, and C

E) None of these

5) Consider the class inheritance.

class B

{

public:

B();

B(int nn);

void f();

void g();

private:

int n;

};

class D: private B

{

public:

D(int nn, float dd);

void h();

private:

double d;

};

Which of the following functions can be invoked by an object of class D?

a) f()

b) g()

c) h()

d) All the above

6) A derived class object inherits all the members of the base class. Which of these remarks about the

inherited member variables is not true?

a) Inherited members are need to be allocated memory and should be initialized at creation of a

derived class object.

b) Inherited members are will be automatically managed by the C++ runtime system, so can be

safely ignored.

c) Inherited members memory allocation must be done by the base class constructor for the base

class, which must be called.

d) The base class constructor is the most convenient place to initialize these inherited variables.

7) The function

int fact(int k) {

return k*fact(k-1);

if (k==0) return 1;

}

a) works for all non-negative values of k, but not for negative numbers.

b) returns the value 1 if it is passed a value of 0 for the parameter k.

c) does not correctly handle its base case.

d) computes the factorial on an integer k passed to it as parameter.

e) None of the above.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!