C++ Midterm answers
- Get link
- X
- Other Apps
false
T/F When assigning a numeric value to a variable, enclose the variable in single quotes
true
T/F The symbol :: represents the scope resolution operator
false
T/F When you increase an integer beyond its maximum value, you generate an error
true
T/F every variable must have a type that tells your compiler how much memory to set aside and defines what you can legally do with the variable
true
T/F a linker links objects files to external files and creates an executable file
false
T/F a quote is a series of printable characters
false
T/F A postfix increment operator increments a variable before the evaluation of a larger expression involving the variable
false
T/F Inserting comment into code is a waste of time
true
T/F When you declare a variable, you must specify its type
false
T/F Users cannot input values for variables
Assembly
Which of the following is not one of the three typical categories of programming errors
object-oriented programming
Creation of reusable software objects that can be easily incorporated into another program
constant
what is the term for an unchangeable variable
#
what symbol is used to start a preprocessor variabl
syntax
which type of errors occur during compilation
floating
which of the following is NOT a data type
variable name
what do you use to access a variable
main() function
what is the starting point of every program
identifier
when creating an enumeration, what follows the keyword enum
assembly language
what is the lowest-level, human readable programming language that allows programmers to communicate directly with the computer's hardware
postfix decrement operator
which operator is placed after a variable that is being decreased by one
parentheses
what should you use to force operations with lower precedence to occur first
occur during compilation
which of the following is false about link errors
{}
what symbols surround the body of a function
integrated development environment
what does the acronym IDE represent
modifiers
you can use _______ to alter a typ
cout
_____ is an object, defined in the file iotream, that is used to send data to the standard output stream
prefix
the _______ increment operator increments a variable before the evaluation of a larger expression involving the variable
keyword
a _________ is a special word that C++ reserves for its own use
fundamental types
_________ are types that are built into the c++ language
true
T/F Logical operator expressions always evaluate to true or false
false
T/F Linear programs allow the program to skip statements and loop through code
true
T/F Placing a semi-colon at the end of an if statement creates an empty statement that is essentially useless
true
T/F When using Boolean data types, any non-zero value will be interpreted as true
true
T/F With an AND logical operator expression, both conditions must be true for the expression to be true
true
T/F The computer will always produce the same series of random numbers in a program
true
T/F With if statements, if the expression is false, the statement is skipped and the program branches to the statement after the if statement.
false
T/F use Boolean data types to store string data types
true
T/F Operator precedence will define the exact order in which elements of an expression are evaluated
true
T/F Variables must be initialized before being used in a while loops
==
Which of the following represents the equal to relation operator
Not, And, Or
which is the correct order of precedence for logical operators
loop body
what is the term for the group of statements that repeat in a loop
<
which of the following represents the less than relation operator
break
in switch statements, which statement exits the switch structure
bool
what data type should be used to create a boolean variable
unsigned int
what data type gets passed as a seed to the random number generator
<=
which of the following represents the less than or equal to relational operator
&&
which of the following is the AND logical operator
current date and time
which of the following is the perfect object on which to seed the random number generator
continue
what kind of statement do you use to jump directly to the top of a loop
logical operators
what type of operator should you use to create complex expressions
>
which of the following represents the great than relational operator
default
in switch statements, if no value matches the expression an optional _______ case will execute
NOT
which logical operator lets you switch the truth or falsity of an expression
Do
__ loops let you repeat a section of code based on an expression that is tested after each loop itereration
int
switch statements only work with the ___ data type
nesting
when you write one if statement inside another, its called ________
parentheses
if you want an operation with lower precedence to be evaluated first, you can use ________
seed
game programmers give the random number generator a number, called a ____, to determine the starting place in the sequence of pseudorandom numbers
false
T/F The empty() member function returns a string value
true
T/F for loops allow you to repeat a section of code
false
T/F A string object stores a sequence of string values
true
T/F Objects can be stored in varaibles
true
T/F If you do not include a test expression in a for loop, you must provide an exit statement
false
T/F The find() member function returns the string literal from a variable
false
T/F C-style strings have member functions
false
T/F in a for loop, an expression is tested each time after the loop body executes
true
T/F you can use the + operator to combine strings
true
T/F arrays can store elements of programmer-defined types
[]
which of the following is the subscription operator
multidimensional
what is the correct term for an array with two or more dimensions
string member functions
which of the following allows you to combine, change, and erase string objects through familiar operators
bounds checking
Testing to make sure than an index number is a valid array position before using it is called
object
What is the correct term for an encapsulated, cohesive, things that combine qualities and abilities
operator overloading
What is the correct term for redefining a familiar operator so it works differently when using a new, previously undefined context
data member
what is a data element of an object called
string color = 'blue;
Which of the following is NOT a correct way to create a string object
• String characters(4, '*');
• String food="taco";
• String animal("giraffe");
• String color = 'blue;
for loops
To count or move through a sequence of items it is best to use which of the following types of loops
iteration
what is the correct term to describe each pass through a for loop
cstring
which standard library file contains a variety of functions for working the c-style strings
string students[22];
which of the following is a correct declaration of an array
size()
which string member function returns the number of characters in a string object
c-style strings
strings with arrays of characters terminated by a null character are called?
0 through 2
if you have the following array: int highGrades[3]; , which of the following are the correct index numbers
arrays
_____ proved a way to work with elements of any type
concatenating
when you use the + operator to combine string objects, you are _________ the string objects
string object
when you concatenate a string object with a c-style string, you always produce a?
initialization
_________ is a statement that sets up some initial condition for a for loop
nesting
when you put a for loop inside another for loop, it is called ________
true
T/F a vector is considered a dynamic array
true
T/F Iterators are required by the STL algorithms
false
T/F The size() vector member function returns the number of elements that a vector can hold before a program must reallocate more memory for it
true
T/F When using the pop_back() member function to remove an element from a vector, the size of the vector is automatically reduce by one
true
T/F A constant iterator, while not being able to change the element to which it refers, can itself change
false
T/F The nothing() member function returns true if a vector is empty
false
T/F If the find() STL algorithm does no find a match, it returns an iterator to the beginning of the range
false
T/F with associative containers, you can retrieve values in sequence
true
T/F to access the size of a vector element with an iterator, you can use the indirect member selection operator
true
the find() STL algorithm returns an iterator that references the first matching element
clear();
which member function removes all of the elements in a vector
dynamic array
what is the correct term for an array that can grow and shrink in size as needed
standard template library
what does the acronym STL represent
reserve()
which member function gives you control over when a reallocation of additional memory occurs
dereference
which operator should you use with an iterator to display the value of the element to which the iterator refers
size()
which member function brings back the number of elements in a vector
pop_back();
which of the following member functions removes the last element in a vector
vector<int>scores(10,0);
which of the following initializes all of the vector's elements to the same value when declaring the vector
2
how many arguments does the sort() algorithm take
*
which of the following is the dereference operator
vector<int>::const_iterator index;
which of the following is the correct format for declaring a constant iterator
push_back()
which member function adds an element to a vector
cctype
which standard library file includes functions for converting characters to uppercase
scores[1].size();
which of the following is the correct format to call the size() member function of an element, assuming the vector is named scores
#include<algorithms>
which of the following is the correct definition for using STL algorithms
begin
the ______ vector member function returns an iterator that refers to a container's first element
sort
the ____ algorithm sorts the elements of a sequence in ascending order
subscripting
you can index vectors by using the _________ operator
end
the ___ member function returns an iterator one past the last element in a container
insert
the _____ vector member function inserts a new element into a vector just before the element referred to by a given iterator
true
T/F There are ways to break up big programs into smaller, bite-sized chunks of code
true
T/F function prototype declarations must end with a semi-colon
false
T/F function headers must end with a semi-colon
false
T/F when you call a function that has no parameters, it is not necessary to include the ()
false
T/F when a function finishes, control always returns to main()
true
T/F functions can both receive a value and return a value
false
T/F to return a value from a function all you need to do is specify a return type
true
T/F local variables are only visible within the function in which they are declared
true
T/F variables in different functions can have the same name
false
T/F variables continue to exist, even when they go out of scope
false
T/F variables declared inside for loops, while loops, if statements, and switch statements can exist outside their structures
false
T/F when you hide a global variable, you change its value
true
T/F global variables can be changed anywhere in your program
true
T/F once you specify a default argument in a list of parameters, you must specify default arguments for all remaining parameters
true
T/F once you omit an argument in a list of parameters, you must specify default arguments for all remaining parameters
true
T/F when you inline a function, the compiler makes the decision of whether or not to inline the function
false
T/F calling inline functions is much harder than calling non-inlined functions
false
T/F there is no difference between an argument and a parameter
false
T/F an argument must have the same name as the parameter to which it is passed
break large programs into smaller pieces
which of the following is an advantage of using functions
return type
what is the first item you include in the function prototype
comma
what character do you use to separate parametrs
compile
what type of error occurs when the function prototype does not match the function definition
return choice;
which of the following is a valid return statement
compile
what type or error occurs if the parameter types in the function prototypes do not match the parameter types int he function definition
encapsulation
what helps keep independent code truly separate by hiding the details
increased employee motivation
which of the following is not a benefit of reusing software
scope
what is the term that describes where variables can be seen your program
{}
which symbols must be used to work with nested scopes
global
what is the correct term for variables that are accessible form any part of your program
default argument
what is the correct term for a value assigned to a parameter if none is specified
=
what operator do you use to specify a default argument
void setAnswers(int A, int B=3, int C=2);
which of the following is a valid prototype
string answer(string choice);
string answer(int choice);
which of the following is an example of function overloading
argument values
what does the compiler use to determine which overloaded function definition to use
inlining
what is the correct term for asking the compiler to make a copy of a function everywhere
functions
what feature of c++ allows you to break up your programs into manageable chunks
argument
what is the correct term for what you use in a function call to pass a value to a function
parameter
what is the correct term for what you use in a function definition to accept values passed to a function
to determine bottlenecks in a program
why do programmers profile code
declare
before you can call a function you have to ______ it
definition functions
_________ _________ means writing all the code that makes the function work
abstraction
by writing and calling functions, you practice what is known as _________
return
a function ends whenever it hits a ______ statement
assignment
to use a returned value, use the ___________ operator
encapsulation
_________ is when no variable you create in a function, including its parameters, can be directly accessed outside its function
local
variables declared inside a function are called _____ variables
overloading
function ________ allows you to write functions that can accept different sets of arguments
inline
use the _______ keyword before a function to op the function directly into the calling code
- Get link
- X
- Other Apps
Comments
Post a Comment