Ch. 1
The term ;b>hardware</b> refers to :
-the physical components that make up a computer.
At the heart of a computer is its central processing unit. The CPU's job is to :
-do all of these
Prewritten code from the run-time libraries must be added to the object code by the <i>linker</i>, and then an executable file is created.
-TRUE
An integrated development environment (IDE) normally includes :
-all of these
The purpose of a memory address is :
-to identify the location of a memory cell.
Creating a program requires many steps. Three of these are :
-program design, writing source code, and testing.
Memory locations that can hold data are called:
-variables.
Characters or symbols that perform operations on one or more operands are :
-operators
Software engineering is a field that encompasses designing, writing, testing, debugging, documenting, modifying, and maintaining computer programs.
-TRUE
The computer's main memory is commonly known as:
-RAM
The ________ coordinates the computer's operations by fetching the next instruction and using control signals to regulate the other major computer components. :
-control unit
A(n) ________ is a set of instructions that tells the computer how to solve a problem. :
-program
List five elements that are common to all programming languages. :
-key words, programmer-defined symbols, operators, punctuation, and syntax
Most of the lines in a program contain something meaningful; however, some of the lines may contain nothing at all.:
-TRUE
Once a value has been stored in a variable it cannot be changed. :
-FALSE
The purpose of the compiler is to convert object code into source code. :
-FALSE
C++ is an example of :
-a high-level programming language
________ is&#47;are used in a C++ program to mark the beginning or ending of a statement, or to separate items in a list. :
-Punctuation
A set of well-defined steps for performing a task or solving a problem is known as :
-an algorithm
The statements written by the programmer are called :
-source code
Internally, the central processing unit (CPU) consists of two parts&#58; :
-the arithmetic and logic unit (ALU) and the control unit.
Even when there is no power to the computer, data can be held in :
-Secondary storage devices
Words with a special meaning that may be used only for their intended purpose are known as:
- key words
A storage location in the computer's memory that can hold a piece of data is called a(n):
-variable
A ________ is a complete instruction that causes the computer to perform some action. :
-statement
A variable definition always specifies the name of a variable and tells :
-what type of data it can hold
Three primary activities of a program are :
-input, processing, and output
Which of the following is an example of a secondary storage device? :
-All
Most modern computers can understand and execute pseudocode :
-False
Mistakes that allow a program to run, but cause it to produce erroneous results are called :
-Logic Erros
What are some of the tools used in the craft of software engineering? :
-program specifications, charts and diagrams of screen output, hierarchy charts, pseudocode, examples of expected input and desired output, and special testing software.
________ is an example of volatile memory, used for temporary storage while a program is running. :
-RAM
If a new value is stored in a variable, it replaces whatever value was previously there. :
- TRUE
Syntax involves rules that must be followed when writing a program. :
-TRUE
In a broad sense, the two primary categories of programming languages are :
-low-level and high-level
Executable code is computer code that contains no errors :
-FALSE
A software package that includes a text editor, compiler, debugger, and assorted utilities for creating, testing, and running software is called :
-an integrated development environment (IDE)
CH 2
You must have a(n) ________ for every variable you intend to use in a program. :
-Definition
The numeric data types in C++ are broken into two categories&#58;:
-char and string.
Because it will probably hold data that contains decimal places, a variable called <font face="Courier New">average</font> should be declared as an integer data
type. :
-FALSE
C++ automatically places ________ at the end of string constants. :
-Null Terminator
Every C++ program must have :
-Comments
In programming terms, a group of characters inside a set of double quotation marks (<font face="Courier New">&quot; &quot;</font>) is called :
-either a string constant or a string literal
Which of the following is&#47;are valid C++ identifiers? :
-Both
CH 3
Program code that can be evaluated to a value is called a(n) :
- expression
If two arithmetic operators in an expression have the same precedence, the order in which their operations are done depends on their :
-Associativity
When the final value of an expression is assigned to a variable, it will be converted to :
- the data type of the variable
The ________ stream manipulator can be used to establish a field width for the value immediately following it :
-setw
The only difference between C-strings and string objects is how they are declared and internally stored. They are used exactly the same way :
-FALSE
Which of the following will allow an entire line of text to be read into a string object, even if it contains embedded blanks?
-getline()
Ch 4
Relational operators allow you to ________ numbers.
- compare
All of the relational operators are binary:
-TRUE
The ________ statement can cause other program statements to execute only under certain conditions. :
-the last answer
To check if a variable has a particular value, use the = relational operator, as in the statement :
-FALSE
is a variable, usually a <font face="Courier New">bool</font>, that signals when a condition exists. :
-flag
The ________ statement executes one block of statements if a test condition is true, and another block if the condition is false. :
-else
A trailing else placed at the end of an <font face="Courier New">if&#47;else</font> <font face="Courier New">if</font> statement provides a default
action when ________ of the <font face="Courier New">if</font> conditions is&#47;are true. :
-none
When an <font face="Courier New">if</font> statement is placed within the conditionally-executed code of another <font face="Courier New">if</font>
statement, this is known as a(n) :
- nested
The rule for matching an statement before it that doesn't have its own
-TRUE
The ________ operator represents logical AND :
-&&
If the sub-expression on the left side of an <font face="Courier New">||</font> operator is true, the expression on the right side will not be checked. :
-TRUE
The three logical operators, AND, OR, and NOT, all have the same precedence. :
-FALSE
The ________ operator takes an operand and reverses its truth or falsehood.:
-the 4th one
The following C++ test checks if the variable
-False
Which of the following correctly declares an enumerated data type named :
-1st one
CH 5
_________ are C++ operators that change their operands by one:
- ++, --
statement can contain an unlimited number of statements, provided they are enclosed in braces:
-TRUE
loop may have a semicolon after the test expression and before the body of the <br/>loop, but it is not required:
-FALSE
loop is somewhat limited, because the counter can only count up, not down.:
-True
while loop is ____ and do-while is :
-pretest, post test
The statements in the body of do-while loop are always excuted :
- at least once
A sentinel is a special value that:
-marks the end of a list of values
statement contains three expressions&#58; initialization, test, and ________.:
- initialization
An initialization expression may be omitted from the <font face="Courier New">for</font> loop if no initialization is required:
-TRUE
You may define a(n) ________ in the initialization expression of a <font face="Courier New">for</font> loop.:
-Variable
When a loop is nested inside another loop, the outer loop goes through all its iterations for each iteration of the inner loop.:
-FALSE
A variable that keeps a running total of data values is called a(n) ________.
-accumulator
If you want to stop a loop before it goes through all its iterations,:
-TRUE
The ________ statement may be used to stop a loop's current iteration and begin the next one. :
-Continue
For data validation, it is best to use a(n):
-while loop
-- operator
-All of these
The increment and decrement operators can be used in relational expressions as well as in arithmetic expressions and in
-TRUE
What will the following code print?
- 5 6 4
a condition that is tested and a statement or block of statements that is repeated as long as the expression ________.
-is TRUE
If nothing with a while loop ever causes the condition to become false, a(n) ________ may occur
-infinite loop
While loop is somewhat limited because the counter can only be increased by one each time through the loop
-FALSE
A(n) ________ is a special value that marks the end of a list of values.
-Sentinel
The ideal type of loop to use if you want a user to enter exactly 20 values is a(n) ________ loop.
- For
The ideal type of loop to use for repeating a menu is a(n) _______ loop
-do-while
Ch 6
Breaking a program up into a set of manageable sized functions is called ________ programming.
-Modular
A function ________ includes the statements that make up the function.
-Definition
In a function header, in addition to the name of the function, you are required to furnish
-All
In a function prototype, in addition to the name of the function, you are required to furnish
-a data type for each parameter and the data type of the return value, but not an identifier name for each parameter
In a function call, in addition to the name of the function, you are required to furnish
-an identifier name or constant for each argument.
The value in ________ local variable is retained between function calls.
-static
When a function just needs to use a copy of an argument passed to it, the argument should normally be passed
-by value
When used as a parameter, a ________ variable allows a function to access and modify the original argument passed to it.
-reference
Two or more functions may have the same name provided that
-the paramete lists are different
When more than one function has the same name they are called ________ functions
-overloaded
If the closing brace of a function body is reached, the flow of control moves to the next function in the file.
-False
The ________ function causes the entire program to terminate, regardless of which function or control mechanism is executing.
-exit
A ________ is a program module whose purpose is to test other modules by calling them.
-driver
A(n) ________ is information that is passed to a function, and a(n) ________ is a special variable that receives and holds that information.
-argument,parameter
A function can have ________ parameters, and it can have either zero or one return value(s).
-zero to many
When a function needs access to an original argument passed to it, for example in order to change its value, the argument needs to be
-passed by reference parameter
A function ________ eliminates the need to place the function definition before all calls to the function.
-prototype
Numeric global variables are ________ by default and numeric local variables are ________ by default.
-initialized to zero, not initialized
Both function headers and function calls must list the data types of all data being passed to the function.
-false
A(n) ________ argument is one that is automatically passed to a parameter when the argument is left out of the function call.
-default
A ________ is a dummy function that is called instead of the actual function it represents, to test that the call to and return from the function are working correctly.
-stub
Ch 7
An abstraction is a ________ model of something.
-General
When a programmer creates an abstract data type, he or she can decide what values are acceptable for the data type, as well as what operations may be performed on it.
-True
Before a structure variable can be created, the structure must be ________.
-Declared
The members of a structure or a union must all be the same data type.
-False
A ________ is required after the closing brace of a structure declaration.
-semicolon
When three different variables of a particular structure type are created, they are said to be separate ________ of the structure type.
-instances
The dot operator allows you to
- access existing structure members
Any mathematical operation that can be performed on regular C++ variables can be performed on structure members.
-TRUE
The data members of a structure can be initialized
-by using method with an initialization list (if the structure contains no objects, such as string objects) or with a constructor, but not method when the data member is
declared with its data type in the struct declaration.
A program includes the following two structure declarations
-none
When a structure is passed ________ to a function, its members are not copied.
-by either method by reference or as a constant reference
A union allows all its members to share the same memory space.
-TRUE
You can define any number of union variables, but each variable can only store and use the value of one of its members at a time.
-TRUE
If Circle is a structure tag, the function header Circle doSomething(Circle c2) could be the header for a function that
-receives a Circle structure as an argument, does something, and returns a Circle structure
A good reason to pass a structure as a constant reference is to
-prevent changes to the structure members
A(n) ________ is a general model of something that includes only it general characteristics.
-abstraction
An Abstract data type (ADT) is a programmer-defined data type that specifies the values the type can hold, the operations that can be performed on them, and how the operations
will be implemented
-FALSE
A ________ is a construct for encapsulating, or packaging together, information that logically belongs together
-structure
Before a structure variable or a union variable can be created, the structure or union must be ________.
-declared
The name of a structure is referred to as its tag.
-TRUE
The members of a structure or a union do not have to all be the same data type.
-TRUE
The ________ allows you to access structure members in a program.
-dot operator
It is possible to nest structures inside other structures.
-TRUE
The following is a legal structure declaration.
-FALSE
Entire structure variables may be passed as arguments to functions and may be returned from functions.
-TRUE
Passing a structure as a constant reference to a function ensures the function
-cannot change any of the structure's members.
Because a union allows all its members to share the same memory space, it is essential that only one of the members be used by the program at any given time.
-TRUE
Members of ________ unions have names, but these unions themselves have no name.
-anonymous
A constructor for a structure
-must have the same name as the structure tag.
Whereas procedural programming centers around functions, object-oriented programming centers around objects.
-TRUE
A class declaration provides a pattern for creating objects, so when a class is declared it automatically creates an object.
-False
Objects are created from abstract data types that encapsulate data and ________ together. </TEXT>
-functions
Objects permit data hiding. This means they can keep functions outside the class from ________ the data.</TEXT>
-doing all of these
An object is a(n) ________ of a class. </TEXT>
-instance
In OOP terminology, an object's member variables are often called its ________, and its member functions are sometimes referred to as its ________. </TEXT>
attributes, methods
A constructor is a public class function that is automatically invoked (i.e. called) whenever a class object is created. </TEXT>
-True
Class declarations are usually stored ________.
-in their own header files
When the body of a member function is defined inside a class declaration, it is called a(an) ________ function. </TEXT>
-inline
A ________ is a member function that is automatically called when a class object is ________. </TEXT>
-both constructor, created and destructor, destroyed
A constructor may have a return type of ________.</TEXT>
-none of these
A destructor can have either zero or one parameters. </TEXT>
-False
When a constructor does not require that any arguments be passed to it, it is called a(n) ________ constructor.</TEXT>
-default
More than one constructor may be defined for a class. </TEXT>
-True
________ member function may be called by a statement in a function that is outside the class. </TEXT>
-A public
A C++ member function that uses, but does not change the value of a member variable is called a(n) ________. </TEXT>
-accessor
Accessors are sometimes called ________ functions and mutators are sometimes called ________ functions. </TEXT>
-get, set
If you do not declare an access specification, the default for members of a class is ________.</TEXT>
-private
If setRadius is a Circle class function and myCircle is a <font Circle object, which of the following statements would set & myCircle</font>'s radius to 2.5
-myCircle.setRadius(2.5);
Ch 8
Unlike regular variables, arrays can hold multiple ________. </TEXT>
-values
The amount of memory used by an array depends solely on the number of elements the array can hold. </TEXT>
-False<
To access an array element, use the array name and the element's ________.</TEXT>
-subscript
If a C++ program contains the following array definition<br/><img align="top" src="ppg/pearson/tm/soceo6/f17g1q4g1.gif"/><br/>the following statement would
store 100 in the first array element&#58;<br/><img align="top" src="ppg/pearson/tm/soceo6/f17g1q4g2.gif"/></TEXT>
-False
The following statement initializes all five elements of the <font face="Courier New">number</font> array to 1.<br/><img align="top"
src="ppg/pearson/tm/soceo6/f17g1q5g1.gif"/></TEXT>
-False
The statement <br/><img align="top" src="ppg/pearson/tm/soceo6/f17g1q6g1.gif"/><br/>is an example of </TEXT>
-implicit array sizing.
To assign the entire contents of one array to another, you can use the assignment operator. </TEXT>
-False
By using the same ________ you can build relationships between data stored in two or more arrays. </TEXT>
-subscript
To step through a one-dimensional array, accessing the elements one by one, it would be most appropriate to use ________ loop. </TEXT>
-a <font face="Courier New">for</font> loop
When an array is passed to a function, it is actually ________ the array that is&#47;are passed. </TEXT>
-the starting memory address of
When you pass an array as an argument to a function, the function can modify the contents of the array. </TEXT>
-True
A two-dimensional array can be viewed as </TEXT>
-a table with rows and columns.
A one-dimensional array can only store elements of a single data type, but a two-dimensional array can hold data of two different data types. </TEXT>
-False
An array of 10 integers named <font face="Courier New">myArray</font> can have its contents displayed with which of the following statements? </TEXT>
-none of these
An element of a two-dimensional array is referenced by the array name and two subscripts, first the element row number and then the element column number. </TEXT>
-True
If you leave out the size declarator in an array declaration
-you must furnish an initialization list.
If the array defined as <font face="Courier New">int myArray[20][10] </font>is being passed to a function named <font face="Courier
New">displayArray</font>, along with information on the number of rows and number of columns currently holding data, which of the following function headers is
correct?
-void displayArray(int myArray[ ][20], int rows, int cols)
Which of the following functions is used to add a new element to a vector that currently has no empty elements? </TEXT>
-push_back()
An array can store a group of values, but the values must be
-all the same data type.
The amount of memory used by an array depends upon the array's data type and how many elements in the array currently have data stored in them. </TEXT>
-False
Subscript numbering in C++
-automatically begins with zero.
The following statement is a valid C++ array definition.<br/><img align="top" src="ppg/pearson/tm/soceo6/f18g1q4g1.gif"/></TEXT>
-False
Each individual element of an array can be accessed by the array name and an element number, called a subscript. </TEXT>
-True
An individual array element can be processed or passed to a function just like a regular C++ variable. </TEXT>
-True
The following array definition is legal because C++ allows arrays to be implicitly sized.<br/><img align="top" src="ppg/pearson/tm/soceo6/f18g1q7g1.gif"/></TEXT>
-False<
You can assign the contents of one array to another by using </TEXT>
-none of these
A one-dimensional array can be initialized at the time it is defined, but a two-dimensional array cannot be. </TEXT>
-False
When an array is passed to a function, it is actually ________ the array that is&#47;are passed. </TEXT>
-the starting memory address of
After carrying out the following two statements, <font face="Courier New">sales</font> will have been created as a one-dimensional array that can hold 20 <font
face="Courier New">double</font> values.<br/><img align="top" src="ppg/pearson/tm/soceo6/f18g1q11g1.gif"/></TEXT>
-True
To add up all the values in a two-dimensional array it would be best to use </TEXT>
-a nested loop
In C++ If you attempt to store more data in an array than it can hold, the compiler will issue an error. </TEXT>
-False
C++ allows arrays to have more than two dimensions. </TEXT>
-True
If the array defined as <font face="Courier New">int myArray[20][10] </font>is being passed to a function named <font face="Courier
New">displayArray</font>, along with information on the number of rows and number of columns, which of the following function <b>calls</b> is correct?
-displayArray(myArray, 20, 10)
When a relationship is established between two or more arrays by using the same subscript to relate entries between the arrays, the arrays are called ________ arrays.</TEXT>
-parallel
A vector created with no elements is ________.
-legal in C++
Assuming <font face="Courier New">employee</font> is an array of structures with a member named <font face="Courier New">hourlyWage</font>, which of the
following statements correctly assigns a value to the <font face="Courier New">hourlyWage</font> member of the first employee structure?
-employee[0].hourlyWage = 20.00
C++ allows array elements to be class objects provided they are all instances of the same class.
-True
Ch 9
A sorting algorithm can be used to arrange a set of ________ in ________ order.
-all of these
The advantage of a linear search is that ________.
-both it is simple and it can be used on unordered data
A(n) ________ search is more efficient than a(n) ________ search
-binary, linear
The linear search is adequate for searching through ________ arrays, but not through ________ ones.
-small, large
Using a linear search, you are more likely to find an item than if you use a binary search.
-False
A binary search begins by examining the ________ element of an array.
-middle
When searching for an item in an <b>unordered</b> set of data, binary search can find the item more quickly than linear search.
-False
The ________ sort usually performs fewer exchanges than the ________ sort.
-selection, bubble
To find a value that is in an unordered array of 100 items, linear search must examine an<b> average</b> of ________ values.
-50
To determine that a item is <u>not</u> in an unordered array of 100 items, linear search must examine an<b> average</b> of ________ values.
-100
To locate a value in an ordered array of 100 items, binary search must examine <b>at most</b> ________ values.
-7
A bubble sort is being used to arrange the following set of numbers in ascending order&#58; <br/>7 5 3 9 2 6<br/>After the first pass of the sort is
completed, what order will the data be in?
-5 3 7 2 6 9
A selection sort is being used to arrange the following set of numbers in ascending order&#58; <br/>7 5 3 9 2 6<br/>After the first pass of the sort is
completed, what order will the data be in?
-2 5 3 9 7 6
We can measure the complexity of an algorithm that solves a computational problem by<br/>determining the number of ________ for an input of size <i>n</i>.
-basic steps it requires
If algorithm A requires 2<i>n</i> + 1<i> </i>basic operations to process an input of size <i>n</i>, and Algorithm B
requires<br/>3<i>n + 2 </i>basic operations to process the same input, algorithm A is considered to be more efficient than Algorithm B.
-False
A ________ algorithm arranges data into some order.
-sorting
A ________ search uses a loop to sequentially step through an array.
-linear
A binary search requires that the elements be in order.
-True
The ________ search is adequate for searching through small arrays, but not through large ones.
-linear </TEXT>
Using a binary search, you are more likely to find an item than if you use a linear search.
-False
Sorted data can be ordered ________.
-all of these are true.
When an array is sorted from highest to lowest, it is said to be in ________ order.
-descending
Any sorting algorithm, such as bubble sort or selection sort, that can be used on data stored in an array can also be used on data stored in a vector.
-True
To determine that a value is <u>not</u> present in an unordered array of 50 items, linear search must examine an<b> average </b>of ________ values.
-50
To locate a value that is in an ordered array of 50 items, linear search must examine <b>at most</b> ________ values.
-50
To locate a value in an ordered array of 50 items, binary search must examine <b>at most</b> ________ values.
-6
A bubble sort is being used to arrange the following set of numbers in ascending order&#58; <br/>8 6 4 9 3 7<br/>After the first pass of the sort is
completed, what order will the data be in?
-6 4 8 3 7 9
A selection sort is being used to arrange the following set of numbers in ascending order&#58; <br/>8 6 4 9 3 7<br/>After the first pass of the sort is
completed, what order will the data be in?
-3 6 4 9 8 7
We can estimate the ________ of an algorithm by counting the number of steps it requires to solve a problem.
-efficiency
CH 10
The ________, also known as the address operator, returns the memory address of a variable.
-ampersand
With pointer variables, you can ________ manipulate data stored in other variables.
-indirectly
With pointer variables you can access, but you cannot modify, data in other variables.
False
The statement int *ptr has the same meaning as
-int* ptr
When you work with a dereferenced pointer, you are actually working with
-the variable whose address is stored in the pointer variable
An array name is a pointer constant because the address stored in it cannot be changed during run-time.
-True
________ can be used as pointers.
-Array names
Which arithmetic operations can be performed on pointers?
-integers may be added to or subtracted from pointers
A pointer may be initialized with
-the address of an existing object of the appropriate type.
The statement *num;
-defines a pointer variable called num
When the less than ( <font face="Courier New">&lt;</font>) operator is used between two pointer variables, the expression is testing whether
-the address of the first variable comes before the address of the second variable in the computer's memory.
Assuming that arr; is an array identifier, the statement sum += * arr;
-adds the value stored in arr[0] to & sum
Variables cannot be created when a program is already running.
-False
The <font face="Courier New">delete</font> operator should only be used on pointers that
-point to storage allocated by the <font face="Courier New">new</font> operator.
A function may return a pointer, but the programmer must ensure that the pointer
-is pointing to an object that is still valid after the return of the function.A
A pointer with the value 0 (zero) is called the <font face="Courier New Baltic">NULL</font> pointer.
-True
Which of the following statements is not valid C++ code?
-all of these are invalid.
Which of the following statements correctly deletes a dynamically-allocated array pointed to by <font face="Courier New">p</font>? -delete [ ] p;
It is legal to subtract a pointer variable from another pointer variable.
-True
The term <i>pointer</i><b> </b>can be used interchangeably with
-address.
The expression <font face="Courier New">s-&gt;m</font> has the same meaning as <font face="Courier New">(*s).m</font>. -True
The expression <font face="Courier New">s-&gt;m</font> is meaningful only when <font face="Courier New Baltic">s</font> is a pointer to a structure
and <font face="Courier New">m</font> is a member of the structure.
-True
You may use a pointer to a structure as a ________.
-all of these
If arr is an array identifier and <font face="Courier New Baltic">k</font> is an integer, the expression <font face="Courier New Baltic">arr[k]</font>
is equivalent to
-*(arr + k) </font>
To dereference a structure pointer and simultaneously access a member of the structure, the appropriate operator to use is&#58;
-the structure pointer operator -&
If the expression const int *p; occurs in a C++ program,
-the compiler will not allow statements that assign to the variable *p.
<?xml version="1.0" encoding="UTF-8"?>
When the ________ is placed in front of a variable name, it returns the address of that variable.
-ampersand
The statement <font face="Courier New">cout &lt;&lt; &amp;num1;</font> will output
-the memory address of the variable called <font face="Courier New">num1</font>
A pointer variable is designed to store ________.
-a memory address
The statement <font face="Courier New">int *ptr; </font>means
-<font face="Courier New">ptr</font> is a pointer variable that will store the address of an integer variable.
C++ does not perform array bounds checking.
-True
A pointer can be passed as an argument to a function.
-True
The statement <font face="Courier New">cout &lt;&lt; *ptr;</font> will output&#58;
-the value stored in the variable whose address is contained in <font face="Courier New">ptr</font>
The ________ and ________ operators can respectively be used to increment and decrement a pointer variable.
- ++, --
Any arithmetic operation may be performed on pointers.
-False
A statement that displays the address of the variable <font face="Courier New">num1</font> is
-4th one
The statement <font face="Courier New">cin &gt;&gt; *p; </font>
-stores the keyboard input into the variable pointed to by <font face="Courier New">p</font>.
Dynamic memory allocation occurs
-when a variable is created at run-time.
The statement <font face="Courier New">int *ptr = new int;</font> acquires memory to hold an integer and then
-sets <font face="Courier New Baltic">ptr</font> to point to the allocated memory.
Any time you use the <font face="Courier New">new</font> operator, it is good practice to
-use <font face="Courier New">delete</font> afterwards to free the memory allocated by <font face="Courier New">new</font>.
Every byte in the computer's memory is assigned a unique
-address.
If dynamically allocated memory is not freed,
-the system may run out of memory.
A reason for passing a pointer to a function is
-to avoid the overhead of copying large data structures and to allow the called function to modify a variable accessible to the calling function are both true.<
The ampersand (<font face="Courier New">&amp;</font>) is used to dereference a pointer variable in C++.
-False
A pointer variable may be initialized with
-the address of an existing variable of the appropriate type.
If a variable occupies more than one byte of memory, its address is
-the address of the first byte of storage allocated to it.
The expression <font face="Courier New">*s-&gt;p;</font> is only meaningful if <font face="Courier New Baltic">s</font> is a pointer to a structure
and <font face="Courier New">p</font> is a pointer that is a member of that structure.
-True
If <font face="Courier New">s</font> is a structure variable and <font face="Courier New">p</font>, a pointer, is a member of the structure, the
statement<br/><img align="top" src="ppg/pearson/tm/soceo6/f22g1q22g1.gif"/>
-output the dereferenced value pointed to by <font face="Courier New">p</font>.
It is possible for a structure to contain as a member a pointer to its own structure type.
-True
If <font face="Courier New">Circle</font> is a structure type, the statement <font face="Courier New">Circle *pcirc;</font><font face="Courier New
Baltic"> </font>
-defines a structure pointer called <font face="Courier New">pcirc</font>
The statement <font face="Courier New">Rectangle * boxPtr;</font><font face="Courier New Baltic"> </font>defines a variable <font face="Courier
New">boxPtr</font> to be a pointer pointing to a type <font face="Courier New">Rectangle</font>.
-True
If the expression <font face="Courier New">const int * const p;</font> occurs in a C++ program,
-Both the compiler will not allow the variable p to be assigned to and the compiler will not allow the variable *p to be assigned to are true.
CH 11
<?xml version="1.0" encoding="UTF-8"?>
<POOL>
<TITLE value="Chapter 011 - Instructor Test Items - Chapter 11, Test 1"/>
<DESCRIPTION>
<TEXT>More About Classes and Object-Oriented Programming </TEXT>
</DESCRIPTION>
<INSTRUCTIONS>The following questions are from the Instructor's Test Item File. We have attempted to match the online content to the printed content as closely as
possible. Some content may have been modified for online presentation or deleted due to the online conversion. We apologize for any inconvenience. We recommend that you
create a new assessment, rather than editing the questions in this directory when you want to use the questions. There are image tags that permit the use of multiple images.
DO NOT edit the /ppg/directory image tags.</INSTRUCTIONS>
<ASSESSMENTTYPE value="quiz"/>
<DATES>
<CREATED value="2007-09-19 17:09:00 EST"/>
</DATES>
<FLAGS>
<ISAVAILABLE value="false"/>
<ISANONYMOUS value="false"/>
<GIVEFEEDBACK value="false"/>
<SHOWCORRECT value="false"/>
<SHOWRESULTS value="false"/>
<ALLOWMULTIPLE value="false"/>
</FLAGS>
<QUESTIONLIST>
<QUESTION id="q1" class="QUESTION_MULTIPLECHOICE" points="1"/>
<QUESTION id="q2" class="QUESTION_MULTIPLECHOICE" points="1"/>
<QUESTION id="q3" class="QUESTION_TRUEFALSE" points="1"/>
<QUESTION id="q4" class="QUESTION_MULTIPLECHOICE" points="1"/>
<QUESTION id="q5" class="QUESTION_TRUEFALSE" points="1"/>
<QUESTION id="q6" class="QUESTION_MULTIPLECHOICE" points="1"/>
<QUESTION id="q7" class="QUESTION_MULTIPLECHOICE" points="1"/>
Each object of a class has its own copy of the class's ________.
-instance member variables
A(n) ________ member variable may be accessed before any objects of the class have been declared.
-static </TEXT>
When a class declares an entire class as its friend, the friendship status is reciprocal. That is, each class's member functions have free access to the other's private
members.
-False
The ________ operator may be used to assign one object to another.
-=
By default, when an object is assigned to another, each member of one object is copied to its counterpart in the other object.
-True
C++ requires that a copy constructor's parameter be a(n) ________.
-reference to an object
C++ allows you to overload
-operators.
When a class contains a pointer to dynamically allocated memory, it is a good idea to equip the class with a
-copy constructor.
When a class contains a pointer to dynamically allocated memory, it a good idea to have the class overload the assignment operator.
-True
If you overload the prefix <font face="Courier New">++</font> operator, the postfix <font face="Courier New">++</font> operator is automatically
overloaded.
-False
A good reason for overloading an operator is to enable it to
-be used with types defined by the programmer.
The process of having a class contain an instance of another class is known as
-object composition.
A public data member may be declared a friend of a private function.
-False
C++ permits you to overload the <font face="Courier New">sizeof</font> operator.
-False
A static member variable can be used when there are no objects of the class in existence.
-True
If you do not furnish a(n) ________, an automatic memberwise copy will be performed when one object is assigned to another object.
-overloaded assignment operator
It is a good idea to make a copy constructor's parameters ________ by specifying the ________ keyword in the parameter list.
-constant, const
A reason to overload the ________ is to write classes that have array-like behavior.
-square brackets <font face="Courier New">[ ] </font>
When you overload the <font face="Courier New">&lt;&lt; </font>operator, you must also overload the <font face="Courier
New">&gt;&gt;</font> operator.
-False
You can overload the conditional operator to make it function as an unconditional operator.
-False
________ allows us to create new classes based on existing classes.
-Inheritance
When you derive a class from an existing class, you
-can add both new data and new functions.
The base class access specification determines how ________ class members may be accessed by derived classes.
-private, public, and protected
________ members of a base class are never accessible to a derived class.
-Private
The ________ class constructor is called before the ________ class constructor.
-base, derived
In an inheritance situation, you can't pass arguments to a base class constructor.
-False
A derived class may become a base class, if another class is derived from it.
-True
In the statement <font face="Courier New Baltic">class </font><font face="Courier New">Car&#58;public Vehicle</font>, which is the base class?
<font face="Courier New">Vehicle</font>
Arguments are passed to the base class destructor function by the ________ class ________ function.
-none of these
The statement <font face="Courier New">class Car&#58;private Vehicle</font> allows the ________ members of the <font face="Courier New">Car</font>
class to access ________ members of the <font face="Courier New">Vehicle</font> class.
-none of these
A member function of a derived class may not have the same name as a member function of a base class.
-False
A derived class may not have any classes derived from it
-False
Some C++ operators cannot be overloaded by the programmer.
-True
If a member variable is declared ________, all objects of that class share access to that variable.
-static
A member function that is declared ________ cannot use the <font face="Courier New">this</font> pointer.
-static
A static member function can be called independently of any object of the class.
-True
A ________ function is not a member of a class, but it has access to the private members of the class.
-friend
It is possible to declare an entire class as a friend of another class.
-True
A(n) ________ is a special function that is called whenever a new object is created and initialized with data from another object of the same class.
-copy constructor
If you do not furnish a(n) ________ for a class, a default will be provided for you by the compiler.
-all of these </TEXT>
When you redefine the way a standard operator works when it is used with class objects, you have ________ the operator.
-overloaded
To overload the <font face="Courier New">+</font> operator, you would write a function called&#58;
-<font face="Courier New">operator +</font><font face="Courier New Baltic"> </font>
The ________ is a special built-in pointer that is available to a class's instance member functions.
-<font face="Courier New">this</font> pointer
You may overload any C++ operator, and you may use the operator function to define non-standard operators, such as <font face="Courier New">@</font> and <font
face="Courier New">^</font>.
-False
The <font face="Courier New">this</font> pointer is a special built-in pointer that is automatically passed as a hidden argument to all instance member functions.
-True
Object composition is useful for creating a ________ relationship between classes.
-has-a
A(n) ________ operator can work with programmer-defined data types.
-overloaded
In C++, if you overload the <font face="Courier New">&lt; </font>operator, you must also overload the<font face="Courier New"> &gt;</font>
operator.
-False
When you overload an operator, you cannot change the number of operands taken by the operator.
-True
A static member function cannot be called if no objects of the class exist.
-False
The structure member selector operator cannot be overloaded.
-True
The <font face="Courier New">this</font> pointer is automatically passed to static member functions of a class.
-False
In the function header, <font face="Courier New">FeetInches FeetInches&#58;&#58;operator++(int)</font><font face="Courier New Baltic">,</font>
the word (<font face="Courier New">int</font>) is known as a(n)&#58;
-dummy parameter.
To dereference an object pointer and access one of the object's members, use the ________.
-<font face="Courier New">-&gt;</font> operator
A constructor that takes a single parameter of a type other than its class is called a convert constructor.
-True
In an inheritance situation, the new class that you create from an existing class is known as the ________.
-both derived class and child class
The base class's ________ affects the way its members are inherited by the derived class.
-access specification <
Protected members of a base class are like ________, with the exception that they may be accessed by derived classes.
-private members
The base class access specification can be viewed as a filter that base class members must pass through when becoming inherited members of a derived class.
-True
The ________ class destructor is called before the ________ class destructor.
-derived, base
When arguments must be passed to the base class constructor, they are passed from the derived class constructor's header line.
-True
________ is commonly used to extend a class, or to give it additional capabilities.
-Inheritance
In the statement <font face="Courier New">class Car&#58;protected Vehicle</font><b>, </b>which is the derived class?
-<font face="Courier New">Car</font>
In the statement <font face="Courier New Baltic">class </font><font face="Courier New">Car&#58;protected Vehicle</font>, what is being protected?
-Base class members
A base class cannot contain a pointer to one of its derived classes.
-True
CH 12
To test if a character is a printable character, use the ________ function.
-isprint
A test using the <font face="Courier New">isupper</font> function will return false if the argument is an uppercase character.
-False
The <font face="Courier New">isdigit</font> function will return true if its argument is a digit.
-True
The ________ is the escape sequence representing the null terminator. -
-3rd one
The null terminator stands for the ASCII code ________.
-0
The ________ function accepts a pointer to a C-string as an argument and returns the length of the string (not including the null terminator).
-3rd one
When using the <font face="Courier New">strcat</font> function, you must be careful not to overflow the bounds of the array allocated for the target string. -True
The <font face="Courier New">strcpy</font> function's arguments are&#58;
-two pointers to <font face="Courier New">char</font>
A library function that looks for the occurrence of one string inside another is&#58;
-strstr
The ________ function accepts a C-string as an argument and converts the string to a long integer.
-atol
The C++ compiler performs strict array bounds checking whenever s an array of characters is being accessed.
-False
The ________ function converts a C-string to an integer and returns the integer value.
-atoi
The <font face="Courier New">itoa</font> function is similar to <font face="Courier New">atoi</font>, but it works in reverse.
-True
By being able to pass arrays as arguments, you can write your own functions for processing C-strings.
-True
Which statement converts the string &quot;<font face="Courier New Baltic">10</font>&quot; to the integer value 10?
-3rd one
The ________ function will return true if its argument is a printable character other than a digit, letter, or space.
-ispunct
The expression isdigit(ch) evaluates to true if <font face="Courier New">ch</font> is&#58;
-both an alphabetic character and <font face="Courier New">&amp;</font>.
Which of the following is considered whitespace?
-all of these.
The library function changecase can be used to change the case of a letter.
-False
Objects of the C++ string class use the<font face="Courier New"> +=</font> operator for concatenation (to append one string to another).
-True
The following statement declares a string object and initializes it to Once upon a time
-True
To test if a character entered is a letter of the alphabet, use the ________ function.
-isalpha
To test if a character is a whitespace character, use the ________ function.
-isspace
To change a character argument from lower to upper case, use the ________ function.
-toupper
The output of the statement cout static_cast char (tolower(toupper('Z'))); is
lower case z.
To account for the null terminator stored at the end of each C-string, the <font face="Courier New Baltic">strlen</font> function returns the number of characters
in its argument, plus one.
-False
A C-string is a sequence of characters stored in consecutive memory, terminated by a
-null character.
To use the <font face="Courier New">strlen</font> function in a program, you must &#35;include ________.
-cstring
The ________ function concatenates the contents of one string with another string.
-strcat
The function ________ accepts pointers to two strings and an integer argument, which indicates how many characters to copy from the second string to the first.
-strncpy
The C++ library provides functions for converting a string representation of a number to a numeric data type, and vice-versa.
-True
The <font face="Courier New">ftoa</font> function converts a floating-point value to an ASCII value.
-False
If a string that cannot be converted to a numeric value is passed to the <font face="Courier New">atoi</font> function, the function's behavior is undefined by C++.
-True
If an upper case character is passed as an argument to<font face="Courier New"> toupper</font>, the result will be an upper case character.
-True
After <font face="Courier New">num = atoi(&quot;1000&quot;);</font> executes, what value is stored in the variable <font face="Courier
New">num</font>? <
-1000
To change a lower case character to an upper case character, use the ________ function.
toupper
The ________ library function reverses the order of a character array.
-none of these
To declare an array that will store students' last names of up to 25 characters in length, which is an appropriate statement?
char lastName[26];
Although C++ provides ample library functions to handle numeric values, we must write all of our own functions to manipulate character values.
-False
The statements <font face="Courier New">char var1 = tolower('A'); cout &lt;&lt; &quot;A&quot;;</font> will result in&#58;
- is output to the monitor.
Ch 13
Data stored ________ is lost when the computer is powered down.
-in RAM
When you assign a name to a file, the operating system identifies the file by that name.
-True
The stream member function <font face="Courier New">fail()</font><font face="Courier New Baltic"> </font>can be used to determine whether the last
operation performed on a stream was successful.
-True
When you store data in a variable, it is automatically saved in a file. <
-False
The ________ data type can be used to create files and write information to them.
-ofstream
Only one file stream object can be declared per C++ program.
-False
Which statement opens a file and links it to a file stream object?
file.open(&quot;filename.txt&quot;); </font>
The process of converting objects that contain pointers to other objects into a form suitable for storage in a file
-is called serialization.
An alternative to using the <font face="Courier New Baltic">open</font> member function is to use the file stream object declaration itself to open the
file.<br/>Example&#58; <font face="Courier New">fstream dataFile(&quot;names.dat&quot;,ios&#58;&#58;in|ios&#58;&#58;out); </font>
-True
A file ________ is a small holding section of memory that file-bound information is first written to.
-buffer
The statement <font face="Courier New">dataFile.close();</font><font face="Courier New Baltic"> </font>
-closes a file.
The ________ may be used to write information to a file.
-stream insertion operator <font face="Courier New">&lt;&lt; </font><font face="Courier New Baltic"> </font>
File output may be formatted the same way as screen output.
-True
The <font face="Courier New">read</font> and <font face="Courier New">write</font> member functions of <font face="Courier
New">fstream</font> objects can only work with buffers specified by pointers to<font face="Courier New"> char</font>.
-True
The operation of moving to a particular location in an input file is accomplished through
-seekg member function
The ________ member function reports when the end of a file has been found.
-eof()
The state bit, ________, can be tested to see if the end of an input stream has been encountered.
-eofbit
The member function, ________, reads a single character from a file.
-get
string objects cannot be stored to a binary file without further processing because they contain pointers.
-True
The ________ function can be used to store binary data to a file.
-write
To access files from a C++ program, you must include
-fstream
To set up a file to perform file I&#47;O, you must declare&#58;
-one or more file stream objects.
ofstream ;ifstream and fstream are
-data types.
A file must be ________ before data can be written to or read from it.
-opened
The ________ data type can be used to connect to files and read information from them into memory.
-ifstream
Opening a file with the flags ios in | ios out will preserve the contents of the file if the file already exists.
-False
Outside of a C++ program, a file is identified by its ________. Inside a C++ program, a file is accessed through a ________.
-name, file stream object
When used by itself, ________ causes a file's contents to be deleted if the file already exists.
-ios out
Which statement opens a file in such a way that information will only be written to its end?
-dataFile.open("info.dat",ios out | ios app);
Closing a file causes any buffered information to be ________.
-saved to the file
To write to a binary file, you can use the write() member function of an ofstream object.
-True
The operating system records the information that tracks the end of the file
-when a file is closed
The ________ may be used to read information from a file.
-stream extraction operator
When a file is opened, the file stream object's &quot;read position&quot; is
-at the beginning of the file.
When the <font face="Courier New">&gt;&gt;</font> operator extracts information from a file, it expects to read data that are separated by ________.
-whitespace
All stream objects have ________ that indicate the condition of the stream.
-error state bits
The state bit ________ is set when an attempted operation has failed.
-ios failbit
The <font face="Courier New">ios&#58;&#58;hardfail </font>bit is set when an unrecoverable error occurs
-True
The member function ________ writes a single character to a file.
-put
The term ________ means non-sequentially accessing information in a file.
-random access