chapter 13 Flashcards

practice (47 cards)

1
Q

1) Objects are created from abstract data types that encapsulate ________ and ________ together.
A) numbers, characters
B) data, functions
C) addresses, pointers
D) integers, floats
E) None of these

A

B

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

In OOP terminology, an object’s member variables are often called its ________, and its member functions are
sometimes referred to as its behaviors, or ________.
A) values, morals
B) data, activities
C) attributes, activities
D) attributes, methods
E) None of these

A

D

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

A C++ class is similar to one of these.
A) inline function
B) header file
C) library function
D) structure
E) None of these

A

c

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

Examples of access specifiers are the key words:
A) near and far
B) opened and closed
C) private and public
D) table and row
E) None of these

A

C

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

This is used to protect important data.
A) public access specifier
B) private access specifier
C) protect() member function
D) class protection oprator , @

A

B

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

Class declarations are usually stored here.
A) on separate disk volumes
B) in their own header files
C) in .cpp files, along with function definitions
D) under pseudonyms
E) None of these

A

B

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

This directive is used to create an “include guard,” which allows a program to be conditionally compiled.
This prevents a header file from accidentally being included more than once.
A) #include
B) #guard
C) #ifndef
D) #endif
E) None of these

A

C

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 said to be ________.
A) static
B) global
C) inline
D) conditional
E) None of these

A

C

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

A ________ is a member function that is automatically called when a class object is ________.
A) destructor, created
B) constructor, created
C) static function, deallocated
D) utility function, declare
E) None of these

A

B

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

The constructor function’s return type is ________.
A) int
B) float
C) char
D) structure pointer
E) None of these

A

E

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

The destructor function’s return type is ________.
A) tilde
B) int
C) float
D) Nothing. Destructors have no return type.
E) None of the above

A

D

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

When a constructor function accepts no arguments, or does not have to accept arguments because of
default arguments, it is called a(n) ________.
A) empty constructor
B) default constructor
C) stand-alone function
D) arbitrator function
E) None of these

A

B

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

This type of member function may be called from a statement outside the class.
A) public
B) private
C) undeclared
D) global
E) None of these

A

A

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

If you do not declare an access specification, the default for members of a class is ________.
A) inline
B) private
C) public
D) global
E) None of these

A

B

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

15) In a procedural program, you typically have ________ stored in a collection of variables, and a set of ________
that perform operations on the data.
A) numbers, arguments
B) parameters, arguments
C) strings, operators
D) data, functions
E) None of these

A

D

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

A class is a(n) ________ that is defined by the programmer.
A) data type
B) function
C) method
D) attribute
E) None of these

A

A

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

17) Members of a class object are accessed with the ________.
A) dot operator
B) cin object
C) extraction operator
D) stream insertion operator
E) None of these

A

A

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

Assuming that Rectangle is a class name, the statement:
Rectangle *BoxPtr;
A) declares an object of class Rectangle
B) assigns the value of *BoxPtr to the object Rectangle
C) defines a Rectangle pointer variable called BoxPtr
D) is illegal in C++
E) None of these

A

C

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

When you dereference an object pointer, use the ________.
A) -> operator
B) <> operator
C) dot operator
D) & operator
E) None of these

20
Q

This type of member function may be called only from a function that is a member of the same class.
A) public
B) private
C) global
D) local
E) None of these

21
Q

he constructor function always has the same name as ________.
A) the first private data member
B) the first public data member
C) the class
D) the first object of the class
E) None of these

22
Q

This is automatically called when an object is destroyed.
A) constructor function
B) specification deallocator
C) destructor function
D) coroner function
E) None of these

23
Q

A class may have this many default constructor(s).
A) only one
B) more than one
C) a maximum of two
D) any number
E) None of these

24
Q

Objects in an array are accessed with ________, just like any other data type in an array.
A) subscripts
B) parentheses
C) #include statements
D) output format manipulators
E) None of these

25
The process of object-oriented analysis can be viewed as the following steps: A) Identify objects, then define objects' attributes, behaviors, and relationships B) Define data members and member functions, then assign a class name C) Declare private and public variables, prototype functions, then write code D) Write the main() function, then determine which classes are needed E) None of these
A
26
When a member function is defined outside of the class declaration, the function name must be qualified with the ________. A) class name, followed by a semicolon B) class name, followed by the scope resolution operator C) name of the first object D) private access specifier E) None of these
B
27
f a local variable and a global variable have the same name within the same program, the ________ resolution operator must be used. A) variable B) ambiguity C) scope D) global E) None of these
C
28
For the following code, which statement is not true? class Point { private: double y; double z; public: double x; }; A) x is available to code that is written outside the class. B) The name of the class is Point. C) x, y, and z are called members of the class. D) z is available to code that is written outside the class.
D
29
Assume that myCar is an instance of the Car class, and that the Car class has a member function named accelerate. Which of the following is a valid call to the accelerate member function? A) Car->accelerate(); B) myCar::accelerate(); C) myCar.accelerate(); D) myCar:accelerate();
C
30
What is the output of the following program? #include using namespace std; class TestClass { public: TestClass(int x) { cout << x << endl; } TestClass() { cout << "Hello!" << endl; } }; int main() { TestClass test; return 0; } A) The program runs, but with no output. B) 0 C) Hello! D) The program will not compile.
C
31
What is the output of the following program? #include using namespace std; class TestClass { public: TestClass(int x) { cout << x << endl; } TestClass() { cout << "Hello!" << endl; } }; int main() { TestClass test(77); return 0; } A) The program runs, but with no output. B) 77 C) Hello! D) The program will not compile.
B
32
What is the output of the following program? #include using namespace std; class TestClass { private: int val; void showVal() { cout << val << endl; } public: TestClass(int x) { val = x; } }; int main() { TestClass test(77); test.showVal(); return 0; } A) The program runs, but with no output. B) 77 C) 0 D) The program will not compile.
D
33
True/False: Whereas object-oriented programming centers on the object, procedural programming centers on functions.
True
34
True/False: Class objects can be defined prior to the class declaration.
False
35
True/False: The constructor function may not accept arguments.
False
36
True/False: A destructor function can have zero to many parameters.
False
37
True/False: More than one constructor function may be defined for a class.
True
38
True/False: More than one destructor function may be defined for a class.
False
39
True/False: Object-oriented programming is centered around the object, which encapsulate together both the data and the functions that operate on the data.
True
40
True/False: You must declare all data members of a class before you declare member functions.
False
41
True/False: You must use the private access specification for all data members of a class.
true
42
True/False: A private member function is useful for tasks that are internal to the class, but is not directly called by statements outside the class.
True
43
True/False: If you do not declare a destructor function, the compiler will furnish one automatically
True
44
True/False: When an object is defined without an argument list for its constructor, the compiler automatically calls the object's default constructor
True
45
True/False: One purpose that constructor functions are often used for is to allocate memory that will be needed by the object.
True
46
True/False: One purpose that destructor functions are often used for is to free memory that was allocated by the object.
True
47
True/False: When using smart pointers to dynamically allocate objects in C++ 11, it is unnecessary to delete the dynamically allocated objects because the smart pointer will automatically delete them.
True