Chapter 11 Flashcards

1
Q

True or False:
The private members of a base class can be directly accessed by a derived class.

A

false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False:
A derived class cannot directly access public members of a base class.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

True or False:
If the derived class does not override a public member function of the base class, you may specify a call to that public member function by using the name of the function and the appropriate parameter list.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

True or False:
The constructors of a derived class can directly initialize only the public data members inherited from the base class of the derived class.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

True or False:
A call to the base class’s constructor is specified in the heading of the definition of a derived class constructor.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

True or False:
The class io is the base class of the C++ istream and ostream.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

True or False:
A derived class can directly access the protected members of the base class.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

True or False:
In protected inheritance, public and protected members of the base class become protected members of the derived class.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

True or False:
If inheritance is private, all members of the base class, including private members, become private members of the derived class.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Inheritance is an example of a(n) _______ relationship.

A

is-a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Classes can create new classes from existing classes. This important feature _________.

A

encourages code reuse

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

___________ is a “has-a” relationship.

A

Composition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Existing classes, from which you create new classes, are called ________ classes.

A

base

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Suppose that bClass is a class. Which of the following statements correctly derives the class dClass from bClass?

A

class dClass: private bClass
{
//classMembersList
};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Consider the following class definition:
class dClass: private bClass
{
//classMembersList
};
The class dClass is derived from the class bClass using the _______ type of inheritance.

A

private

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which of the following is a valid definition fo the derived class bClass?

A

class bClass: public aClass
{
//…
};

17
Q

Which of the following is true about inheritance?

A

The public members of the base class become the public or private member variables of the derived class.

18
Q

Which of the following class definitions makes the public members of the class aClass become the public members of the class bClass?

A

class bClass: public aClass
{
//…
};

19
Q

Which of the following is true about a derived class?

A

A derived class can redefine any public member function of the base class.

20
Q

To ________ a public member function of a base class in the derived class, the corresponding function in the derived class must have the same name, number, and types of parameters.

A

redefine

21
Q

If the corresponding functions in the base class and the derived class have the same name but different sets of parameters, then this function is __________ in the derived class.

A

overloaded

22
Q

Consider the following class definitions:
class bClass
{
public:
void setX(int);
void print() const;
private:
int x;
};
class dClass: public bClass
{
public:
void setXY(int, int);
void print() const;
private:
int y;
};
Which of the following statements correctly redefines the member function print of bClass?

A

void dClass::print() const
{
bClass::print();
cout &laquo_space;“y = “ &laquo_space;y &laquo_space;endl;
}

23
Q

If the derived class classD overrides a public member function functionName of the base class classB, then to specify a call to that public member function of the base class, you must use the statement _________.

A

classB::functionName();

24
Q

Which of the following statements about inheritance is true if memberAccessSpecifier is protected?

A

The public members of the base class become protected members of the derived class.

25
Q

Consider the following class definitions:
class bClass{
public:
void setX(int a);
void print() const;
private:
int x;
};
class dClass: public bClass{
public:
void setXY(int a, int b);
void print() const;
private:
int y;
};
Which of the following correctly sets the values of x and y?

A

void dClass::setXY(int a, int b){
bClass::setX(a);
y = b;
}

26
Q

________ is the ability to combine data, and operations on that data, in a single unit.

A

encapsulation

27
Q

________ is the ability to use the same expression to denote different operations.

A

Polymorphism

28
Q

OOP implements ________.

A

OOD

29
Q

C++ provides ______ functions as a means to implement polymorphism in an inheritance hierarchy, which allows the run-time selection of appropriate member functions.

A

virtual

30
Q

The ______ members of an object form its internal state.

A

private

31
Q

The ________members of an object form its external state.

A

public

32
Q

The constructor of a derived class cannot directly access the _______ member variables of the base class.

A

private

33
Q

The preprocessor directive _________ is used to prevent multiple inclusions of a header file in a program.

A

ifndef

34
Q

If inheritance is public, all protected members of the base class are _______ members of the derived class.

A

protected

35
Q

In ___________ (aggregation), one or more members of a class are objects of another class type.

A

composition

36
Q

In OOD, a program is a collection of interacting _________; in structured programming, a program is a collection of interacting functions.

A

objects

37
Q

C++ provides ________ functions as a means to implement polymorphism in an inheritance hierarchy.

A

vitrual