Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Welcome to All Test Answers

Chapter 16 – C How to Program 6e Multiple Choice Test Bank


 

Download  file with the answers

Not a member!
Create a FREE account here to get access and download this file with answers


Chapter 16: Introduction to Classes and Objects

Section 16.2 Defining a Class with a Member Function

16.2 Q1: C++ functions other than main are executed:
a. Before main executes.
b. After main completes execution.
c. When they are explicitly called by another function.
d. Never.

16.2 Q2: Function headers contain all of the following except:
a. Parentheses.
b. Left brace.
c. Name of function.
d. Return type.

16.2 Q3: Calling a member function of an object requires which item?
a. The dot operator.
b. Open and close braces.
c. The class name.
d. None of the above.

16.2 Q4: In the UML, the top compartment of the rectangle modeling a class contains:
a. The class’s name.
b. The class’s attributes.
c. The class’s behaviors.
d. All of the above.

Section 16.3 Defining a Member Function with a Parameter

16.3 Q1: What is the name of the values the method call passes to the method for the parameters?
a. Arguments.
b. References.
c. Objects.
d. Values.

16.3 Q2: Assuming that text is a variable of type string, what will be the contents of text after the statement cin >> text; is executed if the user types “Hello World!” then presses Enter?
a. “H”
b. “Hello”
c. “Hello World”
d. “Hello World!”

16.3 Q3: Two adjacent parameters are separated by what symbol?
a. Dot.
b. Comma.
c. Parentheses.
d. Braces.

Section 16.4 Data Members, set Functions and get Functions

16.4 Q1: Attributes of a class are also known as:
a. Constructors.
b. Local variables.
c. Data members.
d. Classes.

16.4 Q2: What is the default initial value of a String?
a. “”
b. “default”
c. default
d. None of the above.

16.4 Q3: What type of member functions allow a client of a class to assign values to private data members?
a. Client member functions.
b. Get member functions.
c. Set member functions.
d. None of the above.

Section 16.5 Initializing Objects with Constructors

16.5 Q1: A default constructor has how many parameters?
a. 0.
b. 1.
c. 2.
d. Variable number.

16.5 Q2: A constructor can specify the return type:
a. int.
b. string.
c. void.
d. A constructor cannot specify a return type.

16.5 Q3: The compiler will implicitly create a default constructor if:
a. The class does not contain any data members.
b. The programmer specifically requests that the compiler do so.
c. The class does not define any constructors.
d. The class already defines a default constructor.

Section 16.6 Placing a Class in a Separate File for Reusability

16.6 Q1: A header file is typically given the filename extension:
a. .h
b. .hdr
c. .header
d. .cpp

16.6 Q2: Assuming that GradeBook.h is found in the current directory and the iostream header file is found in the C++ Standard Library header file directory, which of the following preprocessor directives will fail to find its desired header file?
a. #include
b. #include “iostream”
c. #include
d. #include “GradeBook.h”

Section 16.7 Separating Interface from Implementation

16.7 Q1: In the source-code file containing a class’s member function definitions, each member function definition must be tied to the class definition by preceding the member function name with the class name and ::, which is known as the:
a. Member definition linker.
b. Class implementation connector.
c. Source code resolver.
d. Binary scope resolution operator.

16.7 Q2: When compiling a class’s source code file (which does not contain a main function), the information in the class’s header file is used for all of the following, except:
a. Ensuring that the header of each member function matches its prototype.
b. Ensuring that each member function knows about the class’s data members and other member functions.
c. Determining the correct amount of memory to allocate for each object of the class.
d. All of the above are uses that the compiler has for the header file information.

16.7 Q3: When a client code programmer uses a class whose implementation is in a separate file from its interface, that implementation code is merged with the client’s code during the:
a. Programming phase.
b. Compiling phase.
c. Linking phase.
d. Executing phase.

Section 16.8 Validating Data with set Functions

16.8 Q1: To execute multiple statements when an if statement’s condition is true, enclose those statements in a pair of:
a. Parentheses, ( ).
b. Square Brackets, [ ].
c. Braces, { }.
d. Angle brackets, < >.

16.844 Q2: Assuming that the string object text contains the string “Hello!!! “, the “expression text.substr( 2 , 5 ) would return a string object containing the string:
a. “llo!! “.
b. “llo! “.
c. “ello! “.
d. “ello”.

About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!