Chapter 7 Flashcards

Introduction to Classes and Objects

1
Q

True/False: Object-oriented programming is centered around objects that include both data and the functions that operate on them.

A

True

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

True/False: ADT stands for Algorithmic Data Type.

A

False

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

Which of the following statements about ADTs are true:
A) They specify the values the data type can hold.
B) They specify the operations the data type can perform.
C) They hide the details of how the data type is implemented.
D) All of the above.
E) A and B, but not C.

A

D

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

True/False: A class declaration provides a pattern for creating objects, but doesn’t make any objects.

A

True

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

An object typically hides its data, but allows outside code to access it through its …

A

public member functions

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

In OOP terminology, an object’s member variables are often called its [Blank], and its member functions are sometimes referred to as its [Blank].

A

attributes, methods

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

When three different objects of a class are created, they are said to be separate [Blank] of the class.

A

instances

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

When the body of a member function is defined inside a class declaration, it is called a(n) [Blank] function.

A

inline

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

True/False: A constructor is a public class function that is automatically invoked (i.e. called) whenever a class object is created.

A

True

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

True/False: A class must have exactly one constructor.

A

False

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

A constructor may have a return type of …

A

None

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

A constructor that does not require that any arguments be passed to it is called a(n) [Blank] constructor.

A

default

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

A destructor is a member function that …

A

is automatically called when an object is destroyed

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

A(n) [Blank] member function may be called by a statement in a function that is outside of the class.

A

public

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

A C++ member function that uses, but does not change, the value of a member variable is called …

A

an accessor.

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

Accessors are sometimes called [Blank] functions and mutators are sometimes called [Blank] functions.

A

get, set

17
Q

IfCircle is the name of a class, which statements would create a Circle object named myCircle?
A) myCircle Circle;
B) myCircle Circle();
C) Circle myCircle;
D) Circle myCircle();
E) None of the above

A

C

18
Q

18) If setRadius is a Circle class function and myCircle is a Circle object, which of the following
statements would set myCircle’s radius to 2.5?
A) setRadius(2.5);
B) myCircle.setRadius(2.5);
C) Circle.setRadius(2.5);
D) Circle(setRadius(2.5));
E) None of the above

A

B

19
Q

True/False: A structure has member variables, like an object, but they are usually all public and accessed
directly with the dot operator, instead of by calling member functions.

A

True

20
Q
A