CS2 Chapter 13

25 July 2022
4.7 (114 reviews)
40 test answers

Unlock all answers in this set

Unlock answers (36)
question
Hello!
answer
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; }
question
the class
answer
The constructor function always has the same name as ________.
question
Identify objects, then define objects' attributes, behaviors, and relationships
answer
The process of object-oriented analysis can be viewed as the following steps:
question
only one
answer
A class may have this many default constructor(s).
question
default constructor
answer
When a constructor function accepts no arguments, or does not have to accept arguments because of default arguments, it is called a(n) ________.
question
private and public
answer
Examples of access specifiers are the key words:
question
private access specifier
answer
This is used to protect important data.
question
structure
answer
A C++ class is similar to one of these.
question
subscripts
answer
Objects in an array are accessed with ________, just like any other data type in an array.
question
private
answer
If you do not declare an access specification, the default for members of a class is ________.
question
constructor, created
answer
A ________ is a member function that is automatically called when a class object is ________.
question
attributes, methods
answer
In OOP terminology, an object's member variables are often called its ________, and its member functions are sometimes referred to as its behaviors, or ________.
question
myCar.accelerate();
answer
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?
question
inline
answer
When the body of a member function is defined inside a class declaration, it is said to be ________.
question
Nothing. Destructors have no return type.
answer
The destructor function's return type is ________.
question
dot operator
answer
Members of a class object are accessed with the ________.
question
-> operator
answer
When you dereference an object pointer, use the ________.
question
data type
answer
A class is a(n) ________ that is defined by the programmer.
question
data, functions
answer
Objects are created from abstract data types that encapsulate ________ and ________ together.
question
None of these
answer
The constructor function's return type is ________. int float char structure pointer
question
77
answer
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; }
question
data, functions
answer
In a procedural program, you typically have ________ stored in a collection of variables, and a set of ________ that perform operations on the data.
question
The program will not compile.
answer
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; }
question
z is available to code that is written outside the class.
answer
For the following code, which statement is not true? class Point { private: double y; double z; public: double x; };
question
#ifndef
answer
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.
question
True
answer
True/False: Whereas object-oriented programming centers on the object, procedural programming centers on functions.
question
False
answer
True/False: Class objects can be defined prior to the class declaration.
question
False
answer
True/False: The constructor function may not accept arguments.
question
False
answer
True/False: A destructor function can have zero to many parameters.
question
True
answer
True/False: More than one constructor function may be defined for a class.
question
False
answer
True/False: More than one destructor function may be defined for a class.
question
True
answer
True/False: Object-oriented programming is centered around the object, which encapsulate together both the data and the functions that operate on the data.
question
False
answer
True/False: You must declare all data members of a class before you declare member functions.
question
False
answer
True/False: You must use the private access specification for all data members of a class.
question
True
answer
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.
question
True
answer
True/False: If you do not declare a destructor function, the compiler will furnish one automatically.
question
True
answer
True/False: When an object is defined without an argument list for its constructor, the compiler automatically calls the object's default constructor.
question
True
answer
True/False: One purpose that constructor functions are often used for is to allocate memory that will be needed by the object.
question
True
answer
True/False: One purpose that destructor functions are often used for is to free memory that was allocated by the object.
question
True
answer
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.