CS2 chapter 13

Your page rank:

Total word count: 803
Pages: 3

Calculate the Price

- -
275 words
Looking for Expert Opinion?
Let us have a look at your work and suggest how to improve it!
Get a Consultant


What is the output of the following program? #include <iostream> using namespace std; class TestClass { public: TestClass(int x) {cout << x << endl;} TestClass() {cout << "Hello!" << endl; } }; int main() { TestClass test; return 0; }

the class

The constructor function always has the same name as ________.

Identify objects, then define objects’ attributes, behaviors, and relationships

The process of object-oriented analysis can be viewed as the following steps:

only one

A class may have this many default constructor(s).

default constructor

When a constructor function accepts no arguments, or does not have to accept arguments because of default arguments, it is called a(n) ________.

private and public

Examples of access specifiers are the key words:

private access specifier

This is used to protect important data.


A C++ class is similar to one of these.


Objects in an array are accessed with ________, just like any other data type in an array.


If you do not declare an access specification, the default for members of a class is ________.

constructor, created

A ________ is a member function that is automatically called when a class object is ________.

attributes, methods

In OOP terminology, an object’s member variables are often called its ________, and its member functions are sometimes referred to as its behaviors, or ________.


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?


When the body of a member function is defined inside a class declaration, it is said to be ________.

Nothing. Destructors have no return type.

The destructor function’s return type is ________.

dot operator

Members of a class object are accessed with the ________.

-&gt; operator

When you dereference an object pointer, use the ________.

data type

A class is a(n) ________ that is defined by the programmer.

data, functions

Objects are created from abstract data types that encapsulate ________ and ________ together.

None of these

The constructor function’s return type is ________. int float char structure pointer


What is the output of the following program? #include <iostream> using namespace std; class TestClass { public: TestClass(int x) {cout << x << endl;} TestClass() {cout << "Hello!" << endl; } }; int main() { TestClass test(77); return 0; }

data, functions

In a procedural program, you typically have ________ stored in a collection of variables, and a set of ________ that perform operations on the data.

The program will not compile.

What is the output of the following program? #include <iostream> 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; }

z is available to code that is written outside the class.

For the following code, which statement is not true? class Point { private: double y; double z; public: double x; };


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.


True/False: Whereas object-oriented programming centers on the object, procedural programming centers on functions.


True/False: Class objects can be defined prior to the class declaration.


True/False: The constructor function may not accept arguments.


True/False: A destructor function can have zero to many parameters.


True/False: More than one constructor function may be defined for a class.


True/False: More than one destructor function may be defined for a class.


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/False: You must declare all data members of a class before you declare member functions.


True/False: You must use the private access specification for all data members of a class.


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/False: If you do not declare a destructor function, the compiler will furnish one automatically.


True/False: When an object is defined without an argument list for its constructor, the compiler automatically calls the object’s default constructor.


True/False: One purpose that constructor functions are often used for is to allocate memory that will be needed by the object.


True/False: One purpose that destructor functions are often used for is to free memory that was allocated by the object.


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.

Share This

More flashcards like this

NCLEX 10000 Integumentary Disorders

When assessing a client with partial-thickness burns over 60% of the body, which finding should the nurse report immediately? a) ...

Read more


A client with amyotrophic lateral sclerosis (ALS) tells the nurse, "Sometimes I feel so frustrated. I can’t do anything without ...

Read more

NASM Flashcards

Which of the following is the process of getting oxygen from the environment to the tissues of the body? Diffusion ...

Read more

Unfinished tasks keep piling up?

Let us complete them for you. Quickly and professionally.

Check Price

Successful message