Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Multiple Choice: C++ 1.How many type parameters may a function template have? a)none, that is not what the parameters in a function template are called.

Multiple Choice: C++

1.How many type parameters may a function template have?

a)none, that is not what the parameters in a function template are called.

b)1

c)2

d)as many as are needed

2. Suppose class D is derived from class B, and class B has a public member function whose declaration is virtual void f();. Suppose class D has its version of the function, void f(). Here is a function definition and an invocation.

void g( B& b)

{

// other code

b.f();

// other code

};

g( dObject );

Suppose this is embedded in an otherwise correct and complete program. Which version of f() will be called?

a) D::f()

b) B::f()

c) This is illegal. You cant pass

D) object argument for a B reference parameter.

3.Suppose class D is derived from class B, and class B has a public member function whose declaration is void f();. Suppose class D has its version of the function, void f(). Here is a function definition and an invocation.

void g( B& b)

{

// other code

b.f();

// other code

};

g( dObject );

Suppose this is embedded in an otherwise correct and complete program. Which version of f() will be called?

a) D::f()

b) B::f()

c) This is illegal. You cant pass a

D) object argument for a B reference parameter.

4. A pure virtual function is a member function

a) Whose declaration ends with = 0.

b) That is used in a derived class only.

c) That is used in a base class

d) Takes no arguments

e) Member form that is used to force all derived classes to implement that member function or be a pure virtual function member of the derived class.

5. A base/member initialization list is preceded by

a)two colons

b)a dot (or period)

c)a single colon

d)a semicolon

6 A derived class object inherits all the members of the base class. Which of these remarks about the inherited member variables is true?

a) Inherited members are not accessible to the derived class functions so can safely be ignored

b) Inherited members are needed to be allocated memory and should be initialized at creation of a derived class object.

c) Inherited members will be automatically managed by the C++ runtime system, so can be safely ignored.

d) Inherited members memory allocation must be done by the base class constructor for the base class, which must be called.

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

7. Which of the following is correct syntax to declare C++ class B to be a public base class for derived class D

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

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

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

e) class B: public D { };

f) None of the above

8. Given the class declaration, class D : public class B {/**/}; Which of the following is true?

a) public members of B become public members of D

b) private members of D become public members of B

c) protected members of B become protected members of D

d) private members of B become public members of D

e) private members of B are accessible in D.

9. Consider the class inheritance.

class B

{

public:

B();

B(int nn);

void f();

void g();

private:

int n;

};

class D: public B

{

public:

D(int nn, float dd);

void h();

private:

double d;

};

How many private members does an object of class D have?

a.0

b.1

c.2

d.3

e.4

f.5

10. Consider the class inheritance.

class B

{

public:

B();

B(int nn);

void f();

void g();

private:

int n;

};

class D: public 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 of the above

e. none of the above

11.Suppose we have a class D derived from base class B,

class B

{

public:

// other members

void func();

// other members

};

void B::func() { /* body */}

class D: public B

{

public:

// other members

void func();

// other members

};

void D::func() { /* body */}

D dObj;

Make the following call using dObj as calling object:

dObj.func();

Which of the following is the version of func that is called?

a. B::func()

b. D::func()

c. This is illegal.

12.Suppose class Child is derived from class Parent that was in turn derived from class GrandParent. When we declare an object of class Child, three constructors are called: i) Child, ii) Parent, iii )GrandParent.. What is the order?

a. Child, Parent, GrandParent

b. Parent, GrandParent, Child

c. GrandParent, Child, Parent

d. GrandParent, Parent, Child

e. GrandParent, Child, Parent

13. Suppose class Child is derived from class Parent that was in turn derived from class GrandParent. When we destroy an object of class Child, three destructors are called: i) Child, ii) Parent, iii )GrandParent. What is the order?

a.Child, Parent, GrandParent

b.Parent, GrandParent, Child

c.GrandParent, Child, Parent

e.GrandParent, Parent, Child

f.GrandParent, Child, Parent

14.Which of the following is correct for opening a file and attaching it to a file named File.txt? Assume proper file inclusion and proper using directives.

a.open(outStream, File.txt, ios::app)

b.ifstream inStream;

inStream.open(File.txt);

c.ifstream inStream(File.txt);

d.ofstream inStream;

onStream.open(File.txt, ios::app);

e.ifstream inStream(File.txt, ios::app);

15.If you want to examine an input value without actually removing it from the input stream, you can apply a member function of cin to the variable ch, which you are to assume is a char type variable. Which of these does this task?

a.cin.get(ch);

b.cin.put(ch);

c.cin.peek(ch);

d.cin.putback(ch);

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

Deductive And Object Oriented Databases Second International Conference Dood 91 Munich Germany December 18 1991 Proceedings Lncs 566

Authors: Claude Delobel ,Michael Kifer ,Yoshifumi Masunaga

1st Edition

3540550151, 978-3540550150

More Books

Students also viewed these Databases questions

Question

Draft a proposal for a risk assessment exercise.

Answered: 1 week ago