Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

Evaluate each logarithm without using a calculator. log 9 81

Answered: 1 week ago